Cannot restart nginx when listening on UNIX domain sockets

Bug #1957320 reported by Athos Ribeiro
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
nginx (Ubuntu)
Undecided
Unassigned

Bug Description

As discussed in [1], there is a bug in nginx [2] which makes Ubuntu's systemd unit restarts fail when nginx is litening on a unix domain socket. This happens because nginx fails to remove the socket during its shutdown process.

This issue has been reported in Debian in [3], and has been fixed upstream since 1.19.1, with the following patch: [4].

To reproduce the issue, run the following commands from a jammy machine:

# apt install -y nginx
# systemctl stop nginx
# mkdir -p /var/www/files
# echo hello > /var/www/files/hello
# cat << EOF > /run/serve-files.socket
server {
    listen unix:/run/serve-files.socket;
    root /var/www/files;
    location / {
        try_files $uri =404;
    }
}
EOF
# systemctl start nginx

Verify it works with:

# echo -e "GET /hello HTTP/1.0\r\n" | netcat -U /run/serve-files.socket

And restart the service:

# systemctl restart nginx

This will throw an error and the service will end in a failed state.

Verify that the socket file in /run/serve-files.socket was not removed.

Removing the socket file should allow you to restart the service.

[1] https://bugs.launchpad.net/ubuntu/+source/nginx/+bug/1919965
[2] https://trac.nginx.org/nginx/ticket/753
[3] https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=821111
[4] http://hg.nginx.org/nginx/rev/7cbf6389194b

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

Other bug subscribers