Run Ghost and other websites using Nginx Webserver on Ubuntu 16.04

Aug 8, 2018 2 min read
Run Ghost and other websites using Nginx Webserver on Ubuntu 16.04

I will start by assuming that you have a server running and did all the prerequisites. If you don't, you can check this guide that teaches you how to setup a ghost blog

Getting Started

The basic idea of using multiple ghost blogs or multiple webpages is to have "a space" assigned to Nginx, so it can process your requests. Nginx has one server block called default, this means that whatever request is not included in a server block in Nginx, it will go there. You can set your main page as default or any other website (server block)

For instance, let's say you have 2 websites:

They could be both blogs, or static pages or something else, the point is the same, which is to assign it to Nginx.

Let's say that will be our 2nd web and is the 3rd

For you would do as follow:

Assuming you have ghost installed, you will have a .conf created, you can check, if not it's very simple to create it, type: cd /etc/nginx/sites-available/ and check for the file. It should end in .conf.

Open it sudo vim nameOfTheFile.conf and check what's inside, assuming you don't have ssl, it should be simple like this:

Here you are listening on port 80, for ghost you have to find which port node.js is listening and assign it, we'll go over it for the next domain. But this one is great for static pages, it's the basic example.


server {
     listen 80;
     listen [::]:80;

     root /var/www/site2_web;

     index index.html index.htm;

     location / {
          try_files $uri $uri/ =404;

After modifying the file in /etc/nginx/sites-available, we need to create a link to this file to /etc/nginx/sites-enabled, otherwise nothing of this would work. Go to: cd /etc/nginx/sites-enabled and type:

sudo ln -s /etc/nginx/sites-available/

Now let's say you want to add your other domain:, which is a ghost blog, the snippet would be like this:

server {

    root /var/www/site3_web;

    location / {
        proxy_set_header X-Forwarded-For 
        proxy_set_header X-Forwarded-Proto $scheme;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header Host $http_host;

    location ~ /.well-known {
        allow all;

    client_max_body_size 50m;


Notice the difference between the two. Also, where the app is listening.
To make sure that your ghost blog is listening on the same port as node.js, type: sudo netstat -peanut.

Also make sure your folders have the right permissions:
sudo chmod -R 755 /var/www/site2_web
sudo chmod -R 755 /var/www/site3_web

After that restart Nginx: sudo systemctl restart nginx

Great! Next, complete checkout for full access to ArturoFM.
Welcome back! You've successfully signed in.
You've successfully subscribed to ArturoFM.
Success! Your account is fully activated, you now have access to all content.
Success! Your billing info has been updated.
Your billing was not updated.