Ok, I'm feeling a bit stupid about this.

I'm trying to setup a simple Apache reverse proxy setup and I'm hitting a wall. I've had this setup working in the past, but now I just don't see whats going wrong. Heres the setup:

Listen 4050

ServerName lb-test
DocumentRoot /www/app

ProxyRequests Off


<Proxy balancer://cluster>
    BalancerMember http://appserver1:4050 route=appserver1
    BalancerMember http://appserver2:4050 route=appserver2
    Order deny,allow
    Allow from all

ProxyPass /balancer-manager !
ProxyPass / balancer://cluster/ stickysession=BALANCEID
ProxyPassReverse / balancer://cluster/

<Location /balancer-manager>
    SetHandler balancer-manager

    Order deny,allow
    Deny from None
    Allow from all

I can see in the log with debug turned on that requests are being routed to a balancer member, but what is also happening is that the proxy host url is also being inserted into the header.

From the lb host: curl -I localhost

HTTP/1.1 200 OK
Date: Wed, 11 Apr 2012 17:33:18 GMT
Server: thin 1.3.1 codename Triple Espresso
Content-Type: text/html; charset=utf-8
Via: 1.1 appserver2:4050
Via: 1.1 lb-test
Set-Cookie: BALANCEID=hej.appserver2; path=/;

As you can see both hosts are in the header, which is breaking the application. I would think that hitting localhost:80 would not trigger mod_proxy, right? If I hit localhost:4050, the same thing happens. Anyone know whats going on?


  • Can you clarify how the application is breaking due to Via headers? Or is it the Host header on the request that's causing problems? – Shane Madden Apr 11 '12 at 18:27
  • Its probably the host header. Its passing lb-test, appserver2:4050 through to the application. – cg75 Apr 11 '12 at 20:19
  • It should just be sending appserver2:4050, the multi-header format isn't allowed for Host. In any case, Tom's answer should be what you need. – Shane Madden Apr 11 '12 at 20:39
  • I tried that, same problem. Response headers still have: Via 1.1 appserver2:4050, 1.1 lb-test:4050 when i hit http://lb-test:4050/ – cg75 Apr 11 '12 at 21:00
  • Can you capture a request with tcpdump between the proxy and the backend server? Making guesses at the request header fields is a poor substitute for being able to actually see them. – Shane Madden Apr 11 '12 at 21:06

you should set;

ProxyPreserveHost On

in your vhost configuration

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.