How to share nginx log's without sudo to another user?
Solution 1:
For example, like this:
chmod 755 /var/log/nginx && chmod 644 /var/log/nginx/*.log && chmod 644 /var/log/nginx/*.gz
this way anyone will be able to cwd and read the contents of the /var/log/nginx directory and read the *.log files.
You should also check the log rotating configuration so the permissions won't be changed again. For the last several versions of Nginx, up to and including 1.6.2, the file /etc/logrotate.d/nginx
has used the line create 0640 www-data adm
to set permissions when rotating logs. This should be changed to something like create 0644 www-data adm
. It should be noted that this solution allows all users on the server to read all Nginx logs.
Update: logrotate configs also should be updated to include the su www-data adm
to allow the logadm utility to work without complaining about incorrect directory permissions.