Configure Nginx Ghost

In this tutorial, we will setup Nginx as proxy to serve ghost blog on port 80 / http . Nginx is widely used as web server plus it can also be used in various ways like loadbalancer, cacheing server, reverse proxy server etc. The use of nginx web server will boost your ghost server serving speed as well as it is good to proxy the port 2368 with port 80 in security point of view.

Description of our ghost blog server

Server Information Detail
Operating System Ubuntu 14.04 LTS server
Arch x86_64
Ghost Installation Directory /opt/ghost
Nginx Configuration File /etc/nginx
IP Address of Ghost server 192.168.122.185

We expect you have already setup the ghost and nginx server on your system. In case, if it is not setup then we will recommend you to quickly read and follow the below given tutorials to run the ghost and nginx on your server.

Follow the given below tutorials to setup and run the ghost blog on Ubuntu server

1. Install Nginx from source code on Ubuntu 14.04 LTS.
2. Install and run ghost blog on Ubuntu.
3. Create upstart event system for ghost blog on Ubuntu.

Setup Nginx server to serve Ghost blog on HTTP / Port 80

Follow the below given steps to setup the nginx server for ghost blog.

1. Login into your web server and become a super user .

sudo su -

2. Create a new file called ghost in /etc/nginx/sites-available

vi /etc/nginx/sites-available/ghost

Paste below given content.
Note: Replace sharadchhetri.com with your domain name and 192.168.122.185 with your ghost server IP Address.

server {
listen 80;
server_name sharadchhetri.com www.sharadchhetri.com;

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

3. Now create symlink in /etc/nginx/sites-enabled/ . This will enable the new nginx config file called ghost.

cd /etc/nginx/sites-enabled/

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

4. Remove the symlink for default file.
WARNING : If default file is in use by any domain in your server then do not remove . First explore and read the default file settings. We will recommend you to create separate nginx file for each domains you host in nginx web server after removing default file.

unlink /etc/nginx/sites-available/default

5. Check once if nginx configuration is correct .

nginx -t

See the below given screenshot , showing the OK status of nginx -t command

nginx image

6. Restart the nginx service and ghost upstart .

service ghost restart

To use service command to restart/start/stop ghost service. (Read this article to create upstart event for ghost – Create upstart event system for ghost blog on Ubuntu )

service nginx restart 

7. Now open the ghost blog in your web browser.
Type domain name on URL field or server IP address.

ghost nginx image

Enjoy ghost blog up and running on Nginx Web server.

Read Some More Articles

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.