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

I've setup HAProxy with the

option forwardfor

option so it'll pass on the user's IP to PHP via $_SERVER[ "HTTP_X_FORWARDED_FOR" ].

If the page request isn't a POST it's populated fine but if it is then it won't be populated. Any ideas where I've gone wrong?

Thanks everyone!

My whole HAProxy conf file for reference:

    log   local0
    log   local1 notice
    #log loghost    local0 info
    maxconn 4096
    #chroot /usr/share/haproxy
    user haproxy
    group haproxy

    log global
    mode    http
    option  httplog
    option  dontlognull
    retries 3
    option redispatch
    maxconn 4096
    contimeout  5000
    clitimeout  50000
    srvtimeout  50000

listen webfarm :80
    mode http
    balance roundrobin
    option forwardfor
    server webA weight 1 maxconn 2048 check
    server webB weight 1 maxconn 2048 check

listen smtp :25
    mode tcp
    option tcplog
    balance roundrobin

    server smtp check
share|improve this question
up vote 3 down vote accepted

From the HAProxy Manual:

It is important to note that as long as HAProxy does not support keep-alive connections, only the first request of a connection will receive the header. For this reason, it is important to ensure that "option httpclose" is set when using this option.

Examples : # Public HTTP address also used by stunnel on the same machine frontend www mode http option forwardfor except # stunnel already adds the header

# Those servers want the IP Address in X-Client
backend www
    mode http
    option forwardfor header X-Client

See also : "option httpclose"

So you can try the httpclose option, but I would try it after hours or in test in case of a performance penalty?

share|improve this answer
Hey Kyle, you're spot on, that fixed it. – Mark L May 25 '10 at 13:13

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.