Quantcast
Channel: Nginx Forum - How to...
Viewing all articles
Browse latest Browse all 4759

Logging remote IP-address behind load balancer

$
0
0
Hello,

I am sorry to come up with something so seemingly trivial but I am having trouble configuring my nginx server in a way that it logs the remote address of a request which has been passed through a load balancer.

The IP address supposed to be logged is included in the header X-Forwarded-For in the query. Using a guide found at http://wp.sgrosshome.com/2014/03/03/how-to-configure-nginx-logs-to-show-real-ip-when-behind-a-reverse-proxy/ I tried to include the following config statement in the surrounding http {} block in the nginx.conf:

log_format specialLog '$remote_addr forwarded for $http_x_forwarded_for - $remote_user [$time_local] '
'"$request" $status $body_bytes_sent '
'"$http_referer" "$http_user_agent"';

And the respective server blogs have that "specialLog" format appended to their access_log statements.

If I do that the server does not log anything at all anymore. If I remove the "forwarded for $http_x_forwarded_for" from the statement above the logging commences normally, even with that self-defined log format... so I wonder what's wrong with it. Even if the variable $http_forwarded_for was empty I would assume it uses it as empty string, but cease to log anything at all.

$ nginx -v
nginx version: nginx/0.7.65
(from Ubuntu 10.04 Lucid Lynx Server)

Thanks for help.

Viewing all articles
Browse latest Browse all 4759

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>