I configured apache-2.4 on windows as a reverse-proxy for my internal nginx server on linux (I know! But don't ask me why!!). Almost everything works great, except:
I believe I have configured nginx to log the real ip using this header: X-Real-IP
. Reference. Now in my reverse-proxy what do I do to set this header to the IP address of the client so that it can be logged. Note that SSL is a must on apache-2.4. Currently my http-vhosts.conf has this:
<VirtualHost _default_:443>
RequestHeader set X-Forwarded-Proto "https"
RequestHeader set X-Forwarded-Ssl on
RequestHeader set X-URL-SCHEME https
ServerName www.external.gateway:443
ServerAlias external.gateway:443
ErrorLog "C:/Apache24/logs/gateway-error.log"
CustomLog "C:/Apache24/logs/gateway-access.log" common
# ServerAdmin admin@gateway.com
SSLEngine On
SSLCertificateFile C:/Apache24/ssl/external.gateway.crt
SSLCertificateKeyFile C:/Apache24/ssl/external.gateway.key
<Location />
SSLRequireSSL
</Location>
ProxyPreserveHost On
ProxyPass / http://internal.nginx:80/
ProxyPassReverse / http://internal.nginx:80/
</VirtualHost>
PS: I can probably use X-Forwarded-For
in nginx, but I need to know what to do to set that header in apache httpd.conf. Any help is appreciated.
Best Answer
Credit to wurtel
Enable
mod_proxy_http
in apache httpd (reverse-proxy) in the httpd.conf, like so:LoadModule proxy_module modules/mod_proxy.so
LoadModule proxy_http_module modules/mod_proxy_http.so
Use
X-Forwarded-For
to log the IP in nginx (upstream) as mentioned here