2

I need to forward the real ip of the visitor to Apache Load Balancer. I have done it on Nginx successfully by just adding following two lines:

proxy_set_header    X-Real-IP        $remote_addr;
proxy_set_header    X-Forwarded-For  $proxy_add_x_forwarded_for

I also have found above solution (for Nginx) on websites that explain the solution for both Apache and Nginx, but it doesn’t work for Apache. Generally solutions are shared for Apache Servers as a back-end server. However, in my case, Apache is the load balancer. I have also tried mod_rpaf but either it did not work or I couldn’t apply it successfully.

Adam Kipnis
  • 10,175
  • 10
  • 35
  • 48
skalkanci
  • 61
  • 1
  • 7

1 Answers1

2

When acting in a reverse-proxy mode (using the ProxyPass directive, for example), mod_proxy_http adds several request headers in order to pass information to the origin server. These headers are:

X-Forwarded-For The IP address of the client. X-Forwarded-Host The original host requested by the client in the Host HTTP request header. X-Forwarded-Server The hostname of the proxy server.

https://httpd.apache.org/docs/2.4/mod/mod_proxy.html#x-headers

Gábor
  • 371
  • 3
  • 8
  • I have deleted all configuration and reconfigured again. Because I had tried mod_proxy_http before and it was the only module I have tried. Interestingly, this time it worked. I am not sure why it was not working. Probably, configuration conflict or something else. I am really suprised. Thanks alot Gábor. – skalkanci Aug 14 '18 at 11:45