Skip to content

New site configs are not applied by systemctl reload nginx with the default LimitNOFILE — only a full restart works (downtime for likr 400-500. sites) #831

Open

Description

@iamfafakkk

CloudPanel version(s) affected

2.5.1

Description

Adding a site writes the vhost for the new domain and reloads nginx. With the
default LimitNOFILE inherited from systemd (1024 soft), the reload does not
pick up the new configuration: the new site returns 404 / keeps serving the old
config until nginx is fully restarted. A full systemctl restart nginx always
works.

The practical consequence is that the only reliable way to add a site is to
restart nginx, which briefly drops every active connection of every other site
hosted on the server — an outage caused by a routine operation.

Setting LimitNOFILE=500000 through a systemd drop-in makes reload work as
expected, which points at the file-descriptor limit as the root cause. There is
currently no way to set this from the panel, the docs do not mention it, and the
failure is silent: the panel reports the site as created while nginx is still
running the previous configuration.

How to reproduce

  1. Provision a server with CloudPanel defaults, without any systemd override:

    systemctl show nginx -p LimitNOFILE
    # LimitNOFILE=1024:524288
  2. Add a new site from the panel (or add a server { ... } block manually).

  3. Reload and request the new domain:

    systemctl reload nginx
    systemctl status nginx
    curl -I https://new-site.test
  4. Restart and request it again:

    systemctl restart nginx
    curl -I https://new-site.test

Possible Solution

Workaround currently used

sudo mkdir -p /etc/systemd/system/nginx.service.d
sudo tee /etc/systemd/system/nginx.service.d/override.conf > /dev/null <<'EOF'
[Service]
LimitNOFILE=500000
EOF
sudo systemctl daemon-reload
sudo systemctl restart nginx

After this drop-in, systemctl reload nginx applies new configuration correctly
and no restart is needed to add a site.

Solution

  • Ship a higher file-descriptor limit with the nginx package/installer, e.g.
    create /etc/systemd/system/nginx.service.d/override.conf containing
    [Service] and LimitNOFILE=500000, followed by systemctl daemon-reload.
    This is backwards compatible and can be done once at install/update time.
  • Alternatively raise the limit from inside nginx itself by adding
    worker_rlimit_nofile 500000; to the generated /etc/nginx/nginx.conf, so
    the limit no longer depends on the systemd unit.
  • Make the site create/delete flow verify the result instead of trusting the
    reload: run nginx -t before reloading, check the exit code of
    systemctl reload nginx, and when the reload does not take effect either
    retry or surface the error in the panel. A silent "success" while nginx is
    still serving the old configuration is what makes this hard to diagnose.
  • Add a troubleshooting entry in the docs (worker_connections exceed open file resource limit, LimitNOFILE, how to change it), since admins currently
    have no hint that the limit exists.

Additional Context

  • systemctl show nginx -p LimitNOFILE (stock install): <1024:524288>
  • systemctl show nginx -p LimitNOFILE (after override): <500000>
  • nginx -V: <output>
  • Sites on the affected server: <n>
  • systemctl reload nginx; echo $?: <exit code>
  • Old worker processes still alive after reload: <yes/no>

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions