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

Is there any way that I can use Haproxy's ability to modify headers so that if the incoming connection has an X-Forwarded-For header for example I can then take the contents of this and add it into Haproxy's X-Forwarded-For record?

My Current Scenario is a client has setup the following:

  • CloudFlare Takes Connection, sets X-Forwarded-For and connects to Haproxy frontend
  • Haproxy then handles this connection and sets the X-Forwarded-For based on the true IP for the connection received (CloudFlares IP Address)
  • Server receives this request and the X-Forwarded-For entry contains the IP of the CloudFlare proxy rather than the true Client IP.
share|improve this question
up vote 3 down vote accepted

Unless your final server really wants to know what the cloudflare IP address was, if nobody connects directly to haproxy, then just remove option forwardfor so it stops changing the X-Forwarded-For header.

If some connections do not go through cloudflare, you can use option forwardfor except cloudflareipaddress to only set X-Forwarded-For for direct connections.

share|improve this answer

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.