[Service] # systemd's default is 1024:524288, i.e. a *soft* LimitNOFILE of 1024. nginx # inherits that soft limit, so worker_connections 2048 could not actually be # reached and every start logged: # "2048 worker_connections exceed open file resource limit: 1024" # Raise both soft and hard to 65536 so the master's rlimit covers # worker_connections before nginx is even started. LimitNOFILE=65536 # The packaged unit ships Restart=no, so a crashed or OOM-killed nginx stayed # down until someone noticed. nginx is the only thing serving the site, so it # must come back on its own. `on-failure` restarts only abnormal exits, which # keeps an operator-initiated `systemctl stop` from being undone. Restart=on-failure RestartSec=2 # Give in-flight requests time to drain on stop/reload instead of severing # keepalive connections and long-polling SSE streams mid-response. TimeoutStopSec=30