Ghost restart vs nginx restart

Hello,
I am new to using both ghost and nginx.
As far as I understand, nginx is a web server and ghost is on the top of it.
I successfully managed to set up my little blog on EC2 with extra sub domain redirections.
After each modification (mainly in /system/files, or ghost config url), I was doing a ghost restart and a sudo service nginx restart. I realized I dont understand which does what, and then before anything, if nginx is the processus listening to the web port, then what does the ghost processus even do, that would need restarting?
I would greatly appreciate a little bit of light on this, so I acquire the intuition of what should I restart in which situation.
Thank you very much in advance

Hey, so any changes made to ghost, like the url change or whatever will need a ghost restart. The only time you should need to do an nginx restart is if you are actually changing the nginx files. The nginx files are the ones that forward the traffic to your blog, typically located in /etc/nginx. Would guess you almost never need to restart this.

Basically the point of nginx is to forward traffic from your website ports (port 80 or 443) to the port your blog is listening on (default is 2368). Since port 80 and 443 need root access on the server, this prevents your Ghost blog from needing root access which increases security.

Does that make sense?

Hello David, thank you for your quick reply,
I changed files ghost/system/files/*.conf, are those part of nginx files?
It seems like I had to restart nginx after doing that, because it wasnt taking effect after just restarting ghost.
Is there an active ghost processus? What does it do exactly? How are nginx and ghost processes communicating?
Thank you!

I changed files ghost/system/files/*.conf , are those part of nginx files?

Those are ghost related files.

The nginx config is in the /etc/nginx folder. There should be a file that tells nginx what to do with ghost in /etc/nginc/sites.enabled/[file].

Nginx should only really need restarting if that changes, which should be pretty rare! In terms of how they communicate, Nginx simply acts as a proxy, any request to the www.myblog.com gets forwarded on to ghost’s service, which is hosted locally using proxy_pass http://127.0.0.1:2368. That’s all the communication they do.

I assume ghost must keep the nginx config up to date if you change something, like the url of your blog, in which case you would need to restart nginx - but I’m not sure exactly when it updates (I’m using a custom nginx config atm). But my config file looks like this:

server {
	listen 80;
	listen [::]:80;
	
	server_name example.com www.example.com;

	location / {
	 proxy_set_header   X-Real-IP $remote_addr;
	 proxy_set_header   Host      $http_host;
	 proxy_pass         http://127.0.0.1:2368;
	}
}

The only think I think would change it is URL, or SSL certification stuff.

If you change files in ghost/system/files/*.conf, you’re making changes to your nginx config, since those files are linked into /etc/nginx/sites-enabled, so restarting nginx would be necessary

nginx is your webserver that sits in front of Ghost. Ghost focuses on doing one thing, and that’s creating a publishing platform that works. In order to keep Ghost lightweight and simple, Ghost doesn’t do webserver stuff.

Your webserver is responsible for doing things like terminating SSL (since you’re connecting to your instance on the same machine), [optionally] caching assets (for example, your images), etc.

The CLI configured nginx to direct all requests to your domain to ghost (in this case, nginx is proxying traffic from the world to your Ghost instance), and ghost will serve content.

Ghost runs on node in its own process, which is managed by systemd. This process is the core of ghost, and contains the logic for all of the features Ghost provides. Nginx is just directing traffic sent to your domain to this process

1 Like

That’s very clear, thank you!

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