Cannot restart nginx when listening on UNIX domain sockets

Bug #1957320 reported by Athos Ribeiro
8
This bug affects 1 person
Affects Status Importance Assigned to Milestone
nginx (Ubuntu)
Fix Released
Low
Unassigned
Jammy
New
Low
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

Revision history for this message
Athos Ribeiro (athos-ribeiro) wrote :

Adding this to the Ubuntu Server backlog to match LP: #1919965

Changed in nginx (Ubuntu):
importance: Undecided → Low
Revision history for this message
Robie Basak (racb) wrote :

This is presumed fixed in Kinetic (nginx 1.22.0-1ubuntu1) since the upstream release for 1.22.0 (May 2022) was after it was reported fixed upstream in 1.19.1. So I'll swap the task to a Jammy one only.

Changed in nginx (Ubuntu):
status: New → Fix Released
Changed in nginx (Ubuntu Jammy):
importance: Undecided → Low
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers