I'm configuring nginx as a reverse proxy in front of Tomcat 7. I added the following lines to nginx configuration:
set_real_ip_from 127.0.0.1;
...
location / {
proxy_pass http://tomcat;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
But still, I see in Tomcat logs the following picture:
127.0.0.1 - - [10/Jun/2013:11:25:48 +0600] "GET /app/welcome;jsessionid=6C1B02376C5F748C509B28FC7CE416C9 HTTP/1.0" 200 10571
127.0.0.1 - - [10/Jun/2013:11:25:48 +0600] "GET /app/welcome;jsessionid=0BBE0174C1F0E94FDF49610144E809D3 HTTP/1.0" 200 10571
127.0.0.1 - - [10/Jun/2013:11:25:48 +0600] "GET /app/welcome;jsessionid=AD48005AD453F3A0BE46F1AC978F145D HTTP/1.0" 200 10571
Is there any way to force Tomcat to use X-Real-IP header (and write it to log files) without modifying web app?