Change Ghost location on Nginx

November 1, 2014 3.6k views

Hi good people of Digital Ocean,

I installed the Ghost image. Now I want to change the path for Ghost ("<domain>"/blog). How do I do this?

PS: In Nginx


1 Answer

To serve Ghost from a subfolder instead of the root of the domain, you'll need to edit /etc/nginx/sites-enabled/ghost And simply change the location block like:

server {
    listen 80 default_server;
    listen [::]:80 default_server ipv6only=on;

    server_name; # Replace with your domain

    root /usr/share/nginx/html;
    index index.html index.htm;

    client_max_body_size 10G;

    location /blog {
        proxy_pass http://localhost:2368;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header Host $http_host;
        proxy_set_header X-Forwarded-Proto $scheme;
        proxy_buffering off;

And then restart Nginx: service nginx restart

Next you'll also need to update Ghost's configuration file as well. Edit the URL in /var/www/ghost/config.js

config = {
    // ### Production
    // When running Ghost in the wild, use the production environment
    // Configure your URL and mail settings here
    production: {
        url: '',
        mail: {},

And restart Ghost with service ghost restart

You should be all set to go! You can now service files as normal from the Nginx document root as well.

Have another answer? Share your knowledge.