How to Setup Ghost as Intranet Network

2015/07/313 min read
bookmark this
Responsive image

Table of Contents

Introduction

Following the guide on how to setup Ghost (Node.js) on a Windows server, you can set up Ghost as a Production server or use it for local development. This blog shows how to set it up as Production but use it inside the company's network as an Intranet.

After you install all the software and are able to run it on your local server, you need to do the following things to hack the system so you can use it as an Intranet.

Disable URL and IP Address Validation Check

Go to /core/server/config/index.js, find the lines which are doing the URL and hostname checks, and comment them out.


// Check that our url is valid
   //if (!validator.isURL(config.url, {protocols: ['http', 'https'], require_protocol: true})) {
    //    errors.logError(new Error('Your site url in config.js is invalid.'), config.url, 'Please make sure this is a valid url before restarting');

    //    return Promise.reject(new Error('invalid site url'));
    //}


 // Check for valid server host and port values
    // TODO: it's checking the server name to be public.
    //if (!config.server || !(hasHostAndPort || hasSocket)) {
    //    errors.logError(new Error('Your server values (socket, or host and port) in config.js are invalid.'), JSON.stringify(config.server), 'Please provide them before restarting.');

    //    return Promise.reject(new Error('invalid server configuration'));
    //}


Config.js Production Environment Setup

config = {
    // ### Production
    // When running Ghost in the wild, use the production environment
    // Configure your URL and mail settings here
    production: {
        url: 'http://my-development-server/',
        mail: {
			transport: 'SMTP',
				options: {
					service: 'Mailgun',
					auth: {
						user: 'if you use mailgun, then put mailgun's email',
						pass: 'mail gun's password'
					}
				}
			},
        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: 'your server's ip address',
            // Port to be passed to node's `net.Server#listen()`, for iisnode set this to `process.env.PORT`
            port: process.env.PORT
        }
    },

If the other parts are already working, like the site is already up and the web server is running as IIS with iisnode, then you don't need to change anything — just refresh your browser.

Conclusion

Setting up Ghost as an Intranet application requires two main steps: disabling the URL and IP address validation checks in the Ghost core configuration, and configuring the config.js file for your production environment. Once these changes are in place, Ghost will run within your company's internal network without issues.