Package: nginx-common Version: 1.14.2-2+deb10u1 Severity: normal Tags: patch
Hi! In caching proxy configurations, nginx will require `client_body_temp_path` and `proxy_temp_path` directives. Those should logically be somewhere underneat `/run`, preferably under `/run/nginx`. But blindly setting that in the Nginx config works only insofar as those directories already exist: nginx won't create them on the fly. This, arguably, could be fixed in Nginx itself but, in the short term, I have found it easier to just override the systemd service file as follows: # cat /etc/systemd/system/nginx.service.d/runtime.conf [Service] RuntimeDirectory=nginx That simple change is sufficient to get nginx to startup correctly on boot. To reproduce this problem, add those directives to the `http {}` block in `nginx.conf`: client_body_temp_path /run/nginx/client_body_temp; proxy_temp_path /run/nginx/proxy_temp; ... and reboot the server. Nginx should fail to start with: nov 26 19:38:40 cache01 systemd[1]: Starting A high performance web server and a reverse proxy server... nov 26 19:38:40 cache01 nginx[1359]: nginx: [emerg] mkdir() "/run/nginx/client_body_temp" failed (2: No such file or directory) nov 26 19:38:40 cache01 nginx[1359]: nginx: configuration file /etc/nginx/nginx.conf test failed nov 26 19:38:40 cache01 systemd[1]: nginx.service: Control process exited, code=exited, status=1/FAILURE nov 26 19:38:40 cache01 systemd[1]: nginx.service: Failed with result 'exit-code'. nov 26 19:38:40 cache01 systemd[1]: Failed to start A high performance web server and a reverse proxy server. Here's a patch on the .service file that should workaround the problem: --- debian/nginx-common.nginx.service.orig 2019-11-26 14:48:56.755111625 -0500 +++ debian/nginx-common.nginx.service 2019-11-26 14:48:21.170537627 -0500 @@ -18,6 +18,7 @@ [Service] Type=forking PIDFile=/run/nginx.pid +RuntimeDirectory=nginx ExecStartPre=/usr/sbin/nginx -t -q -g 'daemon on; master_process on;' ExecStart=/usr/sbin/nginx -g 'daemon on; master_process on;' ExecReload=/usr/sbin/nginx -g 'daemon on; master_process on;' -s reload Thanks! A. -- System Information: Debian Release: 10.2 APT prefers stable-debug APT policy: (500, 'stable-debug'), (500, 'stable'), (1, 'experimental'), (1, 'unstable') Architecture: amd64 (x86_64) Kernel: Linux 4.19.0-6-amd64 (SMP w/4 CPU cores) Locale: LANG=fr_CA.UTF-8, LC_CTYPE=fr_CA.UTF-8 (charmap=UTF-8), LANGUAGE=fr_CA.UTF-8 (charmap=UTF-8) Shell: /bin/sh linked to /usr/bin/dash Init: systemd (via /run/systemd/system) LSM: AppArmor: enabled Versions of packages nginx-common depends on: ii debconf [debconf-2.0] 1.5.71 ii lsb-base 10.2019051400 nginx-common recommends no packages. Versions of packages nginx-common suggests: pn fcgiwrap <none> pn nginx-doc <none> ii ssl-cert 1.0.39