notagoodcoder
notagoodcoder

Reputation: 65

Apache 2.4 - configure ProxyPass based on full url instead of trailing path

Currently I have the following ProxyPass's configured in my Apache httpd.conf file.

The goal is to have one Proxypass on http://myurl.com:port1/mypath to one balance group, and then have any additional Proxypass go to http://myurl.com:port2/mypath to any additional balance groups.

Here is my code currently as is which only works based on the /mypath apparently and can have no proceeding URL. The problem is my two /mypath's are the same and only differ by port1 and port2 in the URL.

I am currently listening on Port1 and Port2 defined above in Apache, but I have no way currently to distinguish if someone who comes in on myurl.com:port1 will get directed to Group1 or Group2 in the balance manager because the /mypath is the same for both.

<IfModule proxy_module>
   ProxyPass /mypath balancer://Group1/ stickysession=JSESSIONID|jsessionid
   ProxyPass /mypath balancer://Group2/ stickysession=JSESSIONID|jsessionid
    <Proxy balancer://Group1>
            BalancerMember ajp://myurl.com:portX/mypath route=TC01
    </Proxy>
    <Proxy balancer://Group2>
            BalancerMember ajp://myurl.com:portY/mypath route=TC01
    </Proxy>
</IfModule>

The below does not work but this is essentially what I am trying to do:

<IfModule proxy_module>
   ProxyPass http://myurl.com:port1/mypath balancer://Group1/ stickysession=JSESSIONID|jsessionid
   ProxyPass http://myurl.com:port2/mypath balancer://Group2/ stickysession=JSESSIONID|jsessionid
    <Proxy balancer://Group1>
            BalancerMember ajp://myurl.com:portX/mypath route=TC01
    </Proxy>
    <Proxy balancer://Group2>
            BalancerMember ajp://myurl.com:portY/mypath route=TC01
    </Proxy>
</IfModule>

Upvotes: 1

Views: 2659

Answers (1)

Dusan Bajic
Dusan Bajic

Reputation: 10899

Since ProxyPass cannot occur within <If> section, seems like you are left with splitting your configuration in two VirtualHosts:

<VirtualHost *:port1>
    ServerName myurl.com
    <Proxy balancer://Group1>
        BalancerMember ajp://myurl.com:portX/mypath route=TC01
    </Proxy>
    ProxyPass /mypath balancer://Group1/ stickysession=JSESSIONID|jsessionid
</VirtualHost>

<VirtualHost *:port2>
    ServerName myurl.com
    <Proxy balancer://Group2>
        BalancerMember ajp://myurl.com:portY/mypath route=TC01
    </Proxy>
    ProxyPass /mypath balancer://Group2/ stickysession=JSESSIONID|jsessionid
</VirtualHost>

Upvotes: 1

Related Questions