Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Until the last few days we had the following architecture: HAProxy -> 2 Backend servers

Now we have: HAProxy -> Varnish -> 2 Backend servers

Before, HAProxy was setting the "X-FORWARDED-FOR" header correctly every time. Now however, it only sets the header sometimes.

By sometimes I mean: I make a request to a PHP script that prints the contents of $_SERVER (holds the header in discussion).

No matter how many times I make the request, HAProxy won't set the header. IF however, I make a request to my script, and then quickly (before the request ends) I hit refresh (so basically I'm making 2 simultaneous requests), the header is being set.

Did someone stumble upon this very weird issue and can point me in the right direction?

Note: putting varnish in front of HAProxy is not an option.

share|improve this question
What's the HAProxy configuration look like? – Shane Madden Jul 21 '12 at 0:19
up vote 2 down vote accepted

Most likely you forgot to use "option http-server-close" in your haproxy configuration. It was OK earlier because your backend servers did not enable keep-alive by default.

share|improve this answer
Right on! Thanks. – Eduard Luca Jul 25 '12 at 20:46

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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