I am trying to serve the requests to my Site through Proxy machine using Load balancer. When i try to access the Site by hitting http://PROXYSERVER.com, the HomePage comes up fine retaining the address bar URL with http://PROXYSERVER.com.
Now, when i try to access internal links for example, http://PROXYSERVER.com/services/ then the address bar URLchanges to the APPSERVER URL http://APPSERVER01.com/services/
NOTE: The Page comes up fine but the address bar URL is getting changed.
Expected behaviour is when user requests http://PROXYSERVER.com/services/ then the address bar should retain the proxy URL while serving the request
Here is my code for load balancing,
ProxyRequests off
ServerName PROXYSERVER.com
# WebHead1
BalancerMember http://APPSERVER01:80/ route=node1
# WebHead2
BalancerMember http://APPSERVER02:80/ route=node2
Order Deny,Allow
Deny from none
Allow from all
ProxySet lbmethod=byrequests
#ProxySet lbmethod=bybusyness
ProxySet stickysession=BALANCEID
SetHandler balancer-manager
Order deny,allow
Allow from all
# Point of Balance
ProxyPass /balancer-manager !
ProxyPass / balancer://mycluster/
Any suggestions will be appreciated.
Best Answer
The configuration you posted and the symptoms you describe point to a missing
ProxyPassReverse
directive.Without it any URL's in the Location, Content-Location and URI headers on HTTP redirect responses send by either one of you application servers won't be modified. That exposes the real name/URL of the application server and the visitor will be directed to that URL rather instead of that of the proxy-server.
You would see such headers for instance when you go to a directory
http://example.com/dirname
and omit the trailing slash /.In that case the active application server will send a HTTP 301 "moved permanently" header and append the trailing slash.
A trace with
curl -v proxyserver.com/services
will show something along the lines of:You resolve that by adding the correct ProxyPassReverse directive which tells Apache to rewrite such headers with that of the proxy URI
Depending on the version of Apache you're running you might experience behaviour similar to this older bug and could try explicit ProxyPassReverse directives for each member of the balancer pool: