nginx ignores prefix path

Bug #1899164 reported by Vasya Pupkin
10
This bug affects 1 person
Affects Status Importance Assigned to Milestone
nginx (Ubuntu)
Won't Fix
Undecided
Unassigned

Bug Description

Current nginx build is ignoring prefix path and tries to write to some compiled-in path.

shadowlmd@ubuntu-server-latest:~$ sudo rmdir /var/lib/nginx/*

shadowlmd@ubuntu-server-latest:~$ nginx -p $HOME/nginx -c $HOME/nginx/nginx.conf -t
nginx: [alert] could not open error log file: open() "/var/log/nginx/error.log" failed (13: Permission denied)
nginx: the configuration file /home/shadowlmd/nginx/nginx.conf syntax is ok
2020/10/09 12:38:03 [emerg] 2702#2702: mkdir() "/var/lib/nginx/body" failed (13: Permission denied)
nginx: configuration file /home/shadowlmd/nginx/nginx.conf test failed

shadowlmd@ubuntu-server-latest:~$ cat $HOME/nginx/nginx.conf
events {
    worker_connections 10;
}
error_log error.log info;
pid nginx.pid;
http {
    access_log access.log combined;
    server {
        listen 127.0.0.1:8123;
        location / {
            return 200 "hello\n";
        }
    }
}

This is happening because of compile time these options:
--error-log-path=/var/log/nginx/error.log --lock-path=/var/lock/nginx.lock --pid-path=/run/nginx.pid --modules-path=/usr/lib/nginx/modules --http-client-body-temp-path=/var/lib/nginx/body --http-fastcgi-temp-path=/var/lib/nginx/fastcgi --http-proxy-temp-path=/var/lib/nginx/proxy --http-scgi-temp-path=/var/lib/nginx/scgi --http-uwsgi-temp-path=/var/lib/nginx/uwsgi

If nginx is built without them, everything works perfectly.

ProblemType: Bug
DistroRelease: Ubuntu 20.04
Package: nginx 1.18.0-0ubuntu1
ProcVersionSignature: Ubuntu 5.4.0-48.52-generic 5.4.60
Uname: Linux 5.4.0-48-generic x86_64
ApportVersion: 2.20.11-0ubuntu27.9
Architecture: amd64
CasperMD5CheckResult: skip
Date: Fri Oct 9 12:31:44 2020
InstallationDate: Installed on 2020-02-04 (248 days ago)
InstallationMedia: Ubuntu-Server 19.10 "Eoan Ermine" - Release amd64 (20191017)
PackageArchitecture: all
ProcEnviron:
 TERM=screen.xterm-256color
 PATH=(custom, no user)
 XDG_RUNTIME_DIR=<set>
 LANG=en_US.UTF-8
 SHELL=/bin/bash
SourcePackage: nginx
UpgradeStatus: Upgraded to focal on 2020-06-29 (102 days ago)

Revision history for this message
Vasya Pupkin (shadowlmd) wrote :
Revision history for this message
Christian Ehrhardt  (paelzer) wrote :

@Thomas - I lack the context knowledge, can you speak to these issues?

Revision history for this message
Thomas Ward (teward) wrote :

paelzer: These are paths chosen by Upstream Debian - we aren't going to alter those compile time paths.

Marking Won't Fix. (If you need an NGINX that works with nonstandard paths, you should probably be compiling NGINX yourself)

Changed in nginx (Ubuntu):
status: New → Won't Fix
Revision history for this message
Thomas Ward (teward) wrote :

NGINX Upstream has similar pre3fixes set in their prebuilt packages as well:

--error-log-path=/var/log/nginx/error.log --http-log-path=/var/log/nginx/access.log --pid-path=/var/run/nginx.pid --lock-path=/var/run/nginx.lock --http-client-body-temp-path=/var/cache/nginx/client_temp --http-proxy-temp-path=/var/cache/nginx/proxy_temp --http-fastcgi-temp-path=/var/cache/nginx/fastcgi_temp --http-uwsgi-temp-path=/var/cache/nginx/uwsgi_temp --http-scgi-temp-path=/var/cache/nginx/scgi_temp

Revision history for this message
Thomas Ward (teward) wrote :

You may be able to fix this by setting `error_log` yourself in your http configuration section.

Anything that's precompiled with a prefix will need **manually overridden** in your nginx.conf file. Either way, this isn't a problem with the packaging, this is a problem with your configuraiton file.

The prefix paths are only applicable if you don't override them in the nginx configuration files. In which case, you should refer to documentation on how to actually override paths and such. Almost all the prefix issues you've mentioned in compiletime can be altered in an nginx.conf to override the compiled-in default prefixes.

So alter your custom nginx.conf accordingly for whatever paths you WANT nginx to use.

This won't be altered in the packaging directly.

Revision history for this message
Vasya Pupkin (shadowlmd) wrote :

@Thomas, this is a bug report, not a request to change paths or anything. I believe it should be reported upstream and tracked here. Nginx should NOT ignore prefix provided on command line with -p switch regardless of paths provided at compile time.

Revision history for this message
Vasya Pupkin (shadowlmd) wrote :

> You may be able to fix this by setting `error_log` yourself in your http configuration section.

Check the config I provided, error_log is defined there. Yet the warning is printed, because nginx tries to access error_log before reading config file. I can start nginx (with a warning) after overriding path of settings I don't even want to use, but do you really believe that's how it supposed to work?

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.