Can't log x-forwarded-for

Francis Daly francis at daoine.org
Tue Aug 2 12:27:52 UTC 2016


On Tue, Aug 02, 2016 at 11:23:46AM +0000, Mik J wrote:

Hi there,

> Thank you very much, it works better, however it works only for access_log for some reason

log_format defines a format that access_log uses.

http://nginx.org/r/access_log

> nginx.conf
> http {log_format   main    '$remote_addr forwarded for $http_x_real_ip - $remote_user [$time_local] ' '"$request" $status $body_bytes_sent ' '"$http_referer" "$http_user_agent"';
> sites-available/defaultserver {...access_log /var/log/nginx/default.access.log main;error_log /var/log/nginx/default.error.log;
> Witherror_log /var/log/nginx/default.error.log main;

http://nginx.org/r/error_log

error_log takes and optional "level", but does not take a "format".

> Nginx fails to start# nginx
> nginx: [emerg] invalid log level "main" in /etc/nginx/sites-enabled/default:13
> The documentation only talks about access_log. Do you think it's normal ?

Yes, that piece is acting as it should.

Cheers,

	f
-- 
Francis Daly        francis at daoine.org



More information about the nginx mailing list