Question

I have my linode running with nginx and passenger running rails application. Now I have created new domain called blog.domain.com I have created a blog using ghost blogger I am unable to understand how to point my blog domain to ghost blog. Where I need to change nginx configuration or config.js in ghost blogger.

Here is my config.js

var path = require('path'),
    config;

config = {
    development: {
        url: 'http://my-ghost-blog.com',

``

        database: {
            client: 'sqlite3',
            connection: {
                filename: path.join(__dirname, '/content/data/ghost-dev.db')
            },
            debug: false
        },
        server: {
            port: '2368'
        }
    },
    production: {
        url: 'http://my-ghost-blog.com',
        mail: {},
        database: {
            client: 'sqlite3',
            connection: {
                filename: path.join(__dirname, '/content/data/ghost.db')
            },
            debug: false
        },
        server: {
            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'
        }
    },
    testing: {
        url: 'http://127.0.0.1:2369',
        database: {
            client: 'sqlite3',
            connection: {
                filename: path.join(__dirname, '/content/data/ghost-test.db')
            }
        },
        server: {
            host: '127.0.0.1',
            port: '2369'
        }
    },
    travis: {
        url: 'http://127.0.0.1:2368',
        database: {
            client: 'sqlite3',
            connection: {
                filename: path.join(__dirname, '/content/data/ghost-travis.db')
            }
        },
        server: {
            host: '127.0.0.1',
            port: '2368'
        }
    }
};
module.exports = config;
Was it helpful?

Solution

To enable a custom domain for your blog you need to change the configuration of Ghost and nginx.

First you have to change the url: values in config.js to your domain name.

development: {
    url: 'http://blog.domain.com',
...
production: {
    url: 'http://blog.domain.com',

Second, nginx need to pass requests to the blog. The configuration should be in /etc/nginx/.

server {

    listen   80;
    listen   [::]:80;

    server_name  blog.domain.com;

    location / {
        proxy_pass          http://localhost:2368/;
        proxy_set_header    Host $host;
        proxy_buffering     off;
   }
} 

After changing the configuration Ghost and nginx need restart.

OTHER TIPS

You can checkout my how to here but the basic idea is:

If you currently have a website running on an Nginx web server and you are interested in installing Ghost on a subdomain you just need to add a small change to your nginx default.conf.

The Nginx default location for your website is /usr/share/nginx/html so we are going to stick with that. We are going to make the primary website in the directory /usr/share/nginx/html/example.com and the Ghost blog in /usr/share/nginx/html/blog.example.com.

To tell Nginx about our new blog we need to edit the nginx default.conf file. The file by default is located at /etc/nginx/conf.d/default.conf. Edit that file:

sudo vi /etc/nginx/conf.d/default.conf

Now at the very bottom of the file add in the following (changing the server_name to your site):

 #Following section for blog.example.com
 server {
     listen 80;
     server_name  blog.example.com;

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

     }
 }

Now just restart nginx and your change will take affect.

sudo service nginx restart

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top