30 Dec 19:26
Keep client ip address
> I have the following system:
> - a machine doing NAT that sends all connections of port 9000 (testing
> purposes) to a machine turning nginx 4.14 at 192.168.1.21.
> - This machine sends the requests to 192.168.1.15, a machine running
> apache with mod_python and django.
>
> The forwarding works just great, but I would like the logs of Apache
> to use the client's IP, not 192.168.1.21, in order not to change
> anything for the different sites administrators.
>
> In order to do this, I've this configuration:
>
> server {
> listen 80;
> server_name www.mysite.com;
> # vhost specific logs
> access_log /var/log/nginx/www.mysite.com.access.log combined;
>
> #Set the max size for file uploads to 50Mb
> client_max_body_size 50M;
>
> location / {
> proxy_pass http://192.168.1.15;
> proxy_redirect off;
> proxy_set_header Host $host;
> proxy_set_header X-Real-IP $remote_addr;
> proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
>
> set_real_ip_from 192.168.1.0/24;
(Continue reading)
> proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
>and defined a new log format for my apache server with %{X-Forwarded-For}i
This is like a standard for apache behind a proxy
RSS Feed