August 2017
Intermediate to advanced
278 pages
8h 53m
English
One thing to note when using a reverse proxy is that the headers back to your application will be based on the IP of the proxy. There are two choices here. The first is to use the logs from NGINX as the authoritative for reporting purposes. The second is to manipulate the headers so that we pass the correct IP through to the application. Here's what our updated block directive looks like:
server {
listen 80;
server_name proxy.nginxcookbook.com;
access_log /var/log/nginx/proxy-access.log combined;
location / {
proxy_pass http://127.0.0.1:8000;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header Host $host;
}
}
The X-Forwarded-For header shows the full chain ...
Read now
Unlock full access