I have the following line (plus context) in my nginx.conf
:
http {
proxy_cache_path cache/ keys_zone=auth_cache:10m;
...
Since nginx.conf
is in /etc/nginx
, cache/
corresponds to /etc/nginx/cache
.
drwxr-xr-x. 5 root root 205 Jun 18 16:25/etx/nginx
( I have also tried this with absolute path /apps/nginx/cache/
drwx------. 2 nginx nginx 6 Jun 18 14:42 /apps/nginx
)
In either case, when I try to
$ sudo systemctl start nginx
it fails. journalctl -u nginx
tells me the following:
... nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
... nginx: [emerg] mkdir() "/etc/nginx/cache" failed (13: Permission denied)
... nginx: configuration file /etc/nginx/nginx.conf test failed
(In the alternate scenario, it does say "/apps/nginx/cache"
instead.)
I then tried to
$ sudo systemctl start nginx-debug
and this starts without any issues, error or warning logs. It creates the cache/
directory wherever specified in nginx.conf
, and when I stop it and start the nginx
service, this also starts normally.
I need to understand what causes this, so I can write my automation and configuration management to work out of the box. My two hypotheses are:
- It's a SELinux issue, and service/binary
nginx-debug
has different tags/restrictions tonginx
. - The pre-flight check when starting
nginx
tries to create the directory as a different. unprivileged user, butnginx-debug
skips these checks and thus creates the directory as root or nginx.
Any idea how to efficiently get to the bottom of this? Thanks!