I use NGINX as reverse proxy for apache. However, when visiting, the REMOTE_ADDR
variable is 127.0.0.1 (in web-applications). Yes, HTTP_X_FORWARDED_FOR
sees my IP, but how can i force that REMOTE_ADDR
was same too?
1 Answer
There is specific module for that: mod remoteip
This module is used to treat the useragent which initiated the request as the originating useragent as identified by httpd for the purposes of authorization and logging, even where that useragent is behind a load balancer, front end server, or proxy server.
The module overrides the client IP address for the connection with the useragent IP address reported in the request header configured with the
RemoteIPHeader
directive.
RemoteIPHeader X-Forwarded-For
You probably should not allow any client to set the X-forwarded-For header and only trust the header value when the requests comes from your (reverse) proxy by adding an ACL with trusted hosts with the RemoteIPInternalProxy
or RemoteIPInternalProxyList
directives.
-
1it could be nice if you have expanded the last sentence (with example steps), thanks– T.ToduaNov 26, 2018 at 9:30