Why is nginx.service defined with Restart=no as `systemd` service`

I just checked nginx.service on my environment where I’ve installed Ghost using Ghost-CLI, it shows that the systemd service isn’t set up to restart nginx:

$ systemctl show nginx.service | grep Restart
Restart=no    <==================================================

I don’t see the code in Ghost-CLI that adds systemd service so I suppose it’s been added by the initialization script in my DigitalOcean droplet. But shouldn’t it be restartable? The ghost.service is. As nginx is set up as a reverse-proxy, if it fails the requests won’t get through to Ghost server, right?

You’re correct in that if nginx is not working requests won’t be proxied to Ghost.

While I can’t say if the DO 1-click image explicitly overrides the nginx config, I think when installing nginx via apt (e.g. sudo apt install nginx), the nginx systemd config doesn’t declare a value for restart, so restart probably defaults to no. Here’s an example nginx config:

You can always take a look at the service config, probably located in /etc/systemd/system/multi-user.target.wants/nginx.service as well

Thanks! The config doesn’t set Restart option. It’s clear from systemctl show nginx.service and by observing the config by the path you’ve given:

Preformatted text`Description=A high performance web server and a reverse proxy server

ExecStartPre=/usr/sbin/nginx -t -q -g 'daemon on; master_process on;'
ExecStart=/usr/sbin/nginx -g 'daemon on; master_process on;'
ExecReload=/usr/sbin/nginx -g 'daemon on; master_process on;' -s reload
ExecStop=-/sbin/start-stop-daemon --quiet --stop --retry QUIT/5 --pidfile /run/nginx.pid


But I assume all Ghost environments should have nginx service configured to be restarted automatically, correct? Is it how you have it for your blogs?

My installation is a debian installation that’s hosted with Linode, as I had been using them before I found Ghost, and don’t plan on switching. I installed nginx several years ago, without messing with the systemd config. I’m not planning on changing its (systemd) config, because nginx has been extremely reliable since I installed it; I’m just trusting that the authors know what they’re doing when they’re not specifying whether nginx should restart :smiley:

You better do the switching stuff soon. As the things are a lot more fun here. I have been using Ghost with the linode server. unlike you I have been using the managed Linode server which is powered by Cloudways and it’s been working great for me.

Managed Linode is definitely great! My server is used for a lot more than Ghost, so I don’t plan on using managed since I need the control :wink:

@vikaspotluri123, thanks a lot for your answers!

@BelindaHafford thanks, so do you suggest setting nginx.service to Restart=always?

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.