3

scenario:
OS centos
webserver apache http version 2.2.23
two weblogic servers clustered
two webservers

above are behind a hardware load balancer

Basically wanted to do url redirection and load balancing(without modifying the session) of traffic

when I type agent.abconline.com it should get redirected to app server 192.168.0.1:7001/agent staging.abconline.com should get redirected to 192.168.0.1;7001/staging

the above said I am able to do with mod_rewrite alone, but while trying with mod_proxy and load balancing, I am not able to get redirected to said URL

following are the config

NameVirtualHost *:80
<VirtualHost *:80>
        ServerName agent.abconline.com
        RewriteEngine On

        <Proxy balancer://agentcluster>
         BalancerMember http://192.168.0.1:7003 route=1 loadfactor=50 retry=60
         BalancerMember http://192.168.0.2:7003 route=1 loadfactor=50 retry=60
        </Proxy>

        # Redirect all non-static requests to agent
        RewriteCond %{DOCUMENT_ROOT}/%{REQUEST_FILENAME} !-f
        RewriteRule ^/(.*)$ balancer://agentcluster%{REQUEST_URI} [P,QSA,L]

        ProxyPass /abc-oper balancer://agentcluster/abc-oper
        ProxyPassReverse /abc-oper balancer://agentcluster/abc-oper
        ProxyPreserveHost on

        SetEnv force-proxy-request-1.0 1
        SetEnv proxy-nokeepalive 1

        <Proxy *>
         Order deny,allow
         Allow from all
        </Proxy>

        ErrorLog /apps/apache/logs/agent.abconline.com.error.log
        CustomLog /apps/apache/logs/agent.abconline.com.access.log combined
        LogLevel debug
</VirtualHost>

<VirtualHost *:80>
        ServerName staging.abconline.com
        RewriteEngine On

        <Proxy balancer://stagingcluster>
         BalancerMember http://192.168.0.1:7003 route=1 loadfactor=50 retry=60
         BalancerMember http://192.168.0.2:7003 route=1 loadfactor=50 retry=60
        </Proxy>

        # Redirect all non-static requests to agent
        RewriteCond %{DOCUMENT_ROOT}/%{REQUEST_FILENAME} !-f
        RewriteRule ^/(.*)$ balancer://stagingcluster%{REQUEST_URI} [P,QSA,L]

        ProxyPass /abc-oper balancer://stagingcluster/abc-oper
        ProxyPassReverse /abc-oper balancer://stagingcluster/abc-oper
        ProxyPreserveHost on

        SetEnv force-proxy-request-1.0 1
        SetEnv proxy-nokeepalive 1

        <Proxy *>
         Order deny,allow
         Allow from all
        </Proxy>

        ErrorLog /apps/apache/logs/staging.abconline.com.error.log
        CustomLog /apps/apache/logs/staging.abconline.com.access.log combined
        LogLevel debug
</VirtualHost>
Kara
  • 6,115
  • 16
  • 50
  • 57
user1871258
  • 31
  • 1
  • 2

1 Answers1

0

Your not adding the appropriate /agent and /staging contexts to the reverse-proxy rules, and obviously removing the contexts on the way back out e.g.

RewriteRule      / balancer://stagingcluster/staging%{REQUEST_URI} [P,QSA,L]
ProxyPassReverse / balancer://stagingcluster/staging


# Possibly also require a:
#ProxyHTMLURLMap balancer://stagingcluster/staging   /
arober11
  • 1,969
  • 18
  • 31