skip to Main Content

I have an apache instance running three domains using name based virtual hosting and every domain has resources to reverse proxy them down to an application server. Application server is a JBoss running a since JVM instance (http://x.x.x.x:8080/)

The domains along with their resources are,

www.abc.com
 - alpha
www.def.com
 - beta
www.ghi.com
 - gamma
 - (root URL - no resource)

abd.com and def.com domains have one resource whereas ghi.com has two (root (/) and gamma).

this is how we have setup virtual hosting for three different domains. A sample for abc.com domain is below,

<VirtualHost *>
ServerName abc.com

            Header add Set-Cookie "ROUTEID=.%{BALANCER_WORKER_ROUTE}e; path=/alpha" env=BALANCER_ROUTE_CHANGED
            <Proxy balancer://mycluster1>
                        <LimitExcept POST GET>
                                order Allow,Deny
                                Deny from all
                        </LimitExcept>
                                BalancerMember http://x.x.x.x:8080 route=1 retry=0
                                BalancerMember http://x.x.x.x:8081 route=2 retry=0
                                ProxySet stickysession=ROUTEID
            </Proxy>
        ProxyPass /alpha balancer://mycluster4/alpha
        ProxyPassReverse /alpha balancer://mycluster4/alpha
</VirtualHost>

With all configuration in place when I try accessing these domains,

www.abc.com/alpha  --> works
www.def.com/beta   --> works

www.ghi.com/gamma  --> works
www.ghi.com/       --> works

since ghi.com domain has a root mapping (/) I am able to access resources of other domain through ghi.com and if I remove the root mapping, cross domain resource accessibility does not work.

www.ghi.com/alpha   --> works
www.ghi.com/beta    --> works

I do not want the resources of other domain to be accessed through ghi.com. I cannot remove root mapping from ghi.com virtual host configuration.

We have tried multiple configuration but none has worked out.
I may sound bit non technical here which I apologize, but this is my problem statement and I am looking for for a fix.


update 1: configuration file after fix proposed by pandurang.

NameVirtualHost *
<VirtualHost *>
ServerName ghi.com

    Header add Set-Cookie "ROUTEID=.%{BALANCER_WORKER_ROUTE}e; path=/gamma " env=BALANCER_ROUTE_CHANGED
    Header add Set-Cookie "ROUTEID=.%{BALANCER_WORKER_ROUTE}e; path=/ " env=BALANCER_ROUTE_CHANGED
    <Proxy balancer://mycluster4>
                <LimitExcept POST GET>
                        order Allow,Deny
                        Deny from all
                </LimitExcept>
                        BalancerMember http://x.x.x.x:8080 route=1 retry=0
                        BalancerMember http://x.x.x.x:8081 route=2 retry=0
                        ProxySet stickysession=ROUTEID
    </Proxy>
    ProxyPass /gamma balancer://mycluster4/gamma
    ProxyPassReverse /gamma balancer://mycluster4/gamma
    ProxyPass / balancer://mycluster4/
    ProxyPassReverse / balancer://mycluster4/
    ProxyPass /alpha !
</VirtualHost>

2

Answers


  1. Create Three different Name-based VirtualHost and disable context(alpha and beta) in http://www.ghi.com.

    <VirtualHost www.abc.com>
    ServerName abc.com
    Header add Set-Cookie "ROUTEID=.%{BALANCER_WORKER_ROUTE}e; path=/alpha" env=BALANCER_ROUTE_CHANGED
    <Proxy balancer://mycluster1>
    <LimitExcept POST GET>
    order Allow,Deny
    Deny from all
    </LimitExcept>
    BalancerMember http://x.x.x.x:8080 route=1 retry=0
    BalancerMember http://x.x.x.x:8081 route=2 retry=0
    ProxySet stickysession=ROUTEID
    </Proxy>
    ProxyPass /alpha balancer://mycluster4/alpha
    ProxyPassReverse /alpha balancer://mycluster4/alpha
    </VirtualHost>
    
    <VirtualHost www.def.com>
    ServerName def.com
    Header add Set-Cookie "ROUTEID=.%{BALANCER_WORKER_ROUTE}e; path=/beta" env=BALANCER_ROUTE_CHANGED
    <Proxy balancer://mycluster1>
    <LimitExcept POST GET>
    order Allow,Deny
    Deny from all
    </LimitExcept>
    BalancerMember http://x.x.x.x:8080 route=1 retry=0
    BalancerMember http://x.x.x.x:8081 route=2 retry=0
    ProxySet stickysession=ROUTEID
    </Proxy>
    ProxyPass /beta balancer://mycluster4/beta
    ProxyPassReverse /beta balancer://mycluster4/beta
    </VirtualHost>
    
    <VirtualHost www.ghi.com>
    ServerName ghi.com
    Header add Set-Cookie "ROUTEID=.%{BALANCER_WORKER_ROUTE}e; path=/" env=BALANCER_ROUTE_CHANGED
    <Proxy balancer://mycluster1>
    <LimitExcept POST GET>
    order Allow,Deny
    Deny from all
    </LimitExcept>
    BalancerMember http://x.x.x.x:8080 route=1 retry=0
    BalancerMember http://x.x.x.x:8081 route=2 retry=0
    ProxySet stickysession=ROUTEID
    </Proxy>
    ProxyPass /alpha !
    ProxyPass /beta !
    ProxyPass / balancer://mycluster4/
    ProxyPassReverse / balancer://mycluster4/
    </VirtualHost>
    
    Login or Signup to reply.
  2. Use the below sequence and test.

    ProxyPass /alpha !
    ProxyPass /gamma balancer://mycluster4/gamma
    ProxyPassReverse /gamma balancer://mycluster4/gamma
    ProxyPass / balancer://mycluster4/
    ProxyPassReverse / balancer://mycluster4/
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search