2

I'm trying to get nginx to log access and error logs. My logs currently have very old content, a mix of logs and gzipped logs.

$ ls -la access*.log*
-rw-rw-rw- 1 nobody nogroup       0 Jan  8  2016 access.log
-rw-rw-rw- 1 nobody nogroup 2261400 Jan  7  2016 access.log.1
-rw-rw-rw- 1 nobody nogroup  311947 Dec 30  2015 access.log.10.gz
-rw-rw-rw- 1 nobody nogroup  434744 Dec 29  2015 access.log.11.gz

My configuration is:

user www-data www-data;
error_log /var/log/nginx/error.log info;
...
http {
  access_log /var/log/nginx/access.log combined;
...

Strangely, despite the user declaration the worker processes still run as nobody:

# ps -eo "%U %G %a" | grep nginx
root     root     nginx: master process /usr/local/openresty/nginx/sbin/nginx -c /usr/local/openresty/nginx/conf/nginx.conf
nobody   nogroup  nginx: worker process                                                              
nobody   nogroup  nginx: worker process   

I tried setting the owner of the existing access.log and error.log files to be nobody:nogroup but still it doesn't log anything.

There's nothing (relevant) in syslog.

I have tried a mixture (!) or reloading and restarting nginx after changing the configuration file. Still nothing...

How is my configuration incorrect?

2 Answers2

0

You might want to refer to these topics for configuring nginx user:

How do I change the NGINX user?

why do nginx process run with user nobody

About nginx empty logs I suggest you to empty logs directory or temporary disable Selinux to see if it's causing the trouble setenrofce 0

You can also check if you have the right syntax and error_log directive is in the correct place.

Ali Pandidan
  • 1,739
0

I had the exact same issue, and in the end, I went to my root folder and found out there was another access.log file, in a different location and this other one was being written to.

cd /
find . -name 'access.log'
Patrick Mevzek
  • 10,581
  • 7
  • 35
  • 45