Server Fault Asked by Geo j on February 13, 2021
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.
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:
> GET /services HTTP/1.1
> Host: proxyserver.com
> User-Agent: curl/7.43.0
> Accept: */*
>
< HTTP/1.1 301 Moved Permanently
< Date: Wed, 06 Jan 2016 09:27:31 GMT
< Server: Apache/2.2.15 (CentOS)
< Location: https://appserver01:/services/
< Content-Length: 328
< Connection: close
< Content-Type: text/html; charset=iso-8859-1
<
You resolve that by adding the correct ProxyPassReverse directive which tells Apache to rewrite such headers with that of the proxy URI
# Point of Balance
ProxyPass /balancer-manager !
ProxyPass / balancer://mycluster/
ProxyPassReverse / balancer://mycluster/
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:
ProxyPass /balancer-manager !
ProxyPass / balancer://mycluster/
ProxyPassReverse / balancer://mycluster/
# Ensure that headers sent by application servers get corrected:
ProxyPassReverse / http://APPSERVER01:80/
ProxyPassReverse / http://APPSERVER02:80/
Answered by HBruijn on February 13, 2021
Get help from others!
Recent Questions
Recent Answers
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP