Search code examples
phphaproxy

HTTP_X_FORWARDED_PORT &HTTP_X_FORWARDED_PORTO overrided by ALB infront of it


My task is to forward the Port / proto to phpinfo.php file for that We are running haproxy which is in infront of ALB.

I tried below configuration on frontend part in haproxy.cfg but it's not working:


frontend
        http-request set-header X-Forwarded-Port %[src_port] 
        #option forwardfor
        #http-request set-header X-Forwarded-Port_HA %[req.hdr(X-Forwarded-Port)]

when I checked that phpinfo.php it got overridden by ALB rule?

Any idea how resolve that?


Solution

  • If there is no solution to prevent the ALB from overriding those headers then you can Switch to a TCP listener in the ALB and let HAProxy handle the HTTP logic. A TCP listener won't mess with the HTTP content and will just forward it instead.