dhtrinh02
By:
dhtrinh02

How do I configure my subdomain for nginx and digitalocean?

August 21, 2014 8.3k views

Digital Ocean pre-build image : Ghost 0.5 on Ubuntu 14.04

I followed a few guides, but I can't seem to get it to work correctly, what am I doing wrong? I want davedh2.com to host my personal site, and have blog.davedh2.com for my ghost blog.

my DNS: http://picpaste.com/pics/Screen_Shot_2014-08-21_at_1.45.40_PM-Nz9gcgnR.1408654168.png

my nginx/sites-available file

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

    server_name davedh2.com; # Replace with your domain

    location / {
         root /usr/share/nginx/davedh2;
         index index.html index.htm;
    } 
}

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

    server_name blog.davedh2.com; # Replace with your domain
    access_log /var/log/nginx/ghost.log


    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;
    } 
}

my config.js

// ### Production
    // When running Ghost in the wild, use the production environment
    // Configure your URL and mail settings here
    production: {
        url: 'http://davedh2.com',
        mail: {},
        database: {
            client: 'sqlite3',
            connection: {
                filename: path.join(__dirname, '/content/data/ghost.db')
            },
            debug: false
        },
        server: {
            // Host to be passed to node's `net.Server#listen()`
            host: '127.0.0.1',
            // Port to be passed to node's `net.Server#listen()`, for iisnode set this to `process.env.PORT`
            port: '2368'
        }
    },

Thank you.

2 Answers

That mostly looks right to me. Except if you want the Ghost blog on the subdomain, you should set it in config.js as well:

    production: {
        url: 'http://davedh2.com',

Does the directory /usr/share/nginx/davedh2 actually exist? Is there an index.html file there?

  • Hey Andrew,
    I did create the directory with the index.html in there. Its not loading my index.html on davedh2.com, any idea on what I should try? Thank you.

  • Hey Andrew,

    It works now, thank you.

Hey Andrew,

Yes, I did create the directory, and there is an index.html. I didn't know that I had to execute the command service ghost restart, lol just found about it. Now, I can go back and forth within the blog, but I'm still unable to load my index.html from /urs/share/nginx/davdh2.

as for the config.js do you mean like this? Thank you.

// ### Production
// When running Ghost in the wild, use the production environment
// Configure your URL and mail settings here
production: {
url: 'http://blog.davedh2.com',
mail: {},
database: {
client: 'sqlite3',
connection: {
filename: path.join(__dirname, '/content/data/ghost.db')
},
debug: false
},
server: {
// Host to be passed to node's net.Server#listen()
host: '127.0.0.1',
// Port to be passed to node's net.Server#listen(), for iisnode set this to process.env.PORT
port: '2368'
}
},

production: {
    url: 'http://davedh2.com',
    mail: {},
    database: {
        client: 'sqlite3',
        connection: {
            filename: path.join(__dirname, '/content/data/ghost.db')
        },
        debug: false
    },
    server: {
        // Host to be passed to node's `net.Server#listen()`
        host: '127.0.0.1',
        // Port to be passed to node's `net.Server#listen()`, for iisnode set this to `process.env.PORT`
        port: '2368'
    }
},

// **Developers only need to edit below here**
Have another answer? Share your knowledge.