Obtain part of url in proxy balancer from one balancer member

1.7k Views Asked by At

I have cluster setup of Apache server . Behind this I have 2 Jboss instances which is load balanced by apache.

The configuration look somewhat like the below

   <VirtualHost *:1111>
    ServerAdmin [email protected]
    ServerName www.example.com

    DocumentRoot "/apps"
    ErrorLog "logs/https.www.example.com.-error_log"
    TransferLog "logs/https.www.example.com-access_log"
    LogLevel warn


    <Directory "/apps">
            Options -Indexes +FollowSymLinks
            AllowOverride None
            Order allow,deny
            Allow from all
    </Directory>


    SSLProxyEngine On
    SSLProxyVerify On


    SSLProxyMachineCertificateFile "/apps/apache/conf/ssl/int/proxy.pem"
    SSLProxyCACertificateFile "/apps/apache/conf/ssl/int/cert.pem"


    RewriteEngine On

    Header set Cache-Control "max-age=60, public"

   <Proxy balancer://2node-aa>

            BalancerMember https://app01:8089 route=node1
            BalancerMember https://app02:8089 route=node2

    ProxyPreserveHost On

    ProxyPass /aa balancer://2node/aa stickysession=JSESSIONID|jsessionid
    ProxyPass /static balancer://2node/static stickysession=JSESSIONID|jsessionid

    ProxyPassReverse /aa balancer://2node/aa
    ProxyPassReverse /static balancer://2node/static



    ProxyPass /1/aa https://app01:8089/aa
    ProxyPass /2/aa https://app02:8089/aa

    ProxyPassReverse /1/aa https://app01:8089/aa
    ProxyPassReverse /2/aa https://app02:8089/aa

    ProxyPass /bb  balancer://2node/rest stickysession=JSESSIONID|jsessionid
    ProxyPassReverse /bb balancer://2node/bb

    </VirtualHost>

In the url access certain part of the url i want it to be routed from second node i.e node2 of jboss.

e.g. if i am accessing http://www.example.com/aa/login/login.jsp i need this request to be process by node2 app02 only.

Rest of the request should load balance as normal access. How do i set the apache to do it ?

I have tried lot of rewrite,<Location> and ProxyPassMatch none has worked so far.

Please Help. Thanks in advance.

1

There are 1 best solutions below

0
On

I used the below statement in the configuration file which resolved the issue.

<Proxy balancer://2node-aa>

BalancerMember https://app02:8080 route=node2

</Proxy>

RewriteRule ^/aa/login/(.*)$ balancer://2node-aa%{REQUEST_URI} [P,QSA,L]

This link help me.

apache httpd mod_proxy load balancing with multiple virtual hosts url redirection

-Thanks