Install Ghost Manually on a subdomain.

January 6, 2015 2.3k views

I'm having a hard time installing ghost on my droplet. The guides I found online seems to be missing something.

My droplet run ubuntu 14.04 LTS. I want to run ghost on a subdomain (blog.example.com) . I used the guide to here to add subdomains on nginx and got it working. I followed this guide http://www.howtoinstallghost.com/how-to-install-ghost-on-ubuntu-server-12-04/ until the part "configure ghost" . I changed the config.example.js file adding on the url "blog.example.com" but I left the host untouched.

Can anyone find me a guide that helps me install ghost on a subdomain using nginx that guide us through the whole process until it is working on port 80?

1 Answer

Setting up Ghost to run on a subdomain behind an Nginx reverse proxy shouldn't be much different than setting it up normally. The key is to set the server_name directive in your Nginx configuration file.

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

    server_name blog.example.com

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

    client_max_body_size 10G;

    location / {
        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;
    } 
}

You'll also need to setup a DNS record pointing the subdomain to the server.

For all the details on setting Ghost up with Nginx, check out this tutorial:

by Alex LaFroscia
This is our tutorial on hosting Ghost with Nginx on DigitalOcean.
  • I've been pulling out my hair over this problem, and unfortunately this didn't work for me.

    I have a similar setup (blog.example.com) and my config file is as such:

        server {
            listen 80;
            listen [::]:80;
            server_name blog.example.com;
            root /var/www/example.com/blog/html;
            index index.html index.htm;
            location / {
                try_files $uri $uri/ =404;
                proxy_pass http://127.0.0.1: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;
            }
        }
    

    When I go to the website using blog.example.com, the text loads but nothing else (css, js) and all links give a 404 error. When I load the site using the server IP, it's functions properly. Would having a firewall enabled cause issues?

    Thanks!

    • FIX:

      Using:

      proxy_pass http://127.0.0.1:2368/;
      proxy_set_header Host $host;
      proxy_buffering off;
      

      Solved my problem.

      Cheers!

Have another answer? Share your knowledge.