Welcome! Log In Create A New Profile

Advanced

Re: Can't log x-forwarded-for

Francis Daly
August 02, 2016 08:30AM
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@daoine.org

_______________________________________________
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx
Subject Author Posted

Can't log x-forwarded-for

miky August 01, 2016 07:28PM

Re: Can't log x-forwarded-for

Francis Daly August 02, 2016 04:02AM

Re: Can't log x-forwarded-for

miky August 02, 2016 07:26AM

Re: Can't log x-forwarded-for

Francis Daly August 02, 2016 08:30AM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 160
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready