Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

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:

global
    log 127.0.0.1   local0
    log 127.0.0.1   local1 notice
    #log loghost    local0 info
    maxconn 4096
    #chroot /usr/share/haproxy
    user haproxy
    group haproxy
    daemon
    #debug
    #quiet

defaults
    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 192.168.240.4 weight 1 maxconn 2048 check
    server webB 192.168.240.3 weight 1 maxconn 2048 check

listen smtp :25
    mode tcp
    option tcplog
    balance roundrobin

    server smtp 192.168.240.4:25 check
share|improve this question

1 Answer 1

up vote 2 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 127.0.0.1 # 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

 
discard

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.