Nginx unable to start after configuring access_log option

Creating a bug report/issue

Required Information

  • DietPi version | G_DIETPI_VERSION_CORE=8
  • Distro version | bullseye
  • Kernel version | Linux examen 5.15.76-rockchip64 #22.08.8 SMP PREEMPT Sun Oct 30 10:57:32 CET 2022 aarch64 GNU/Linux
  • SBC model | ROCK64 (aarch64)
  • Power supply used | 5V 3A switching power supply from Pine64
  • SD card used | No SD card used as everything boots off a USB hard drive

Additional Information (if applicable)

  • Software title | nginx
  • Was the software title installed freshly or updated/migrated? freshly
  • Can this issue be replicated on a fresh installation of DietPi? yes

Steps to reproduce

  1. Open up /etc/nginx/nginx.conf
  2. Add “access_log /var/log/nginx/access.log;” underneath the error_log config line.
  3. Restart nginx with systemctl restart nginx.service
  4. Nginx fails to start.
  5. Run systemctl status nginx.service which states nginx: [emerg] "access_log" directive is not allowed here in /etc/nginx/nginx.conf:22
  6. Have to remove the access_log config line and then nginx starts fine.

Expected behaviour

  • After setting the access_log config option, nginx should restart/start without any issues, and then /var/log/nginx/access_log would get written to by nginx with log information.

Actual behaviour

  • Nginx will not start with setting the access_log and therefore the sysadmin will not have any access_log files to look at & to troubleshoot with.

Extra details

  • I experience this same behavior with nginx on other DietPi systems which I have run for over a year. Not sure what needs to be changed to get this to work.
  • The error.log is being written fine on all DietPi systems, so not sure why this isn’t working.
  • The Steps to reproduce section works for setting this up on nginx running on other Linux distros.

I just figured it out by commenting out line access_log off; and then adding access_log /var/log/nginx/access.log; underneath it (in the http block) and then it worked.