Report this

What is the reason for this report?

Adding Ghost blog to existing website

Posted on February 11, 2016

I’ve been trying to add Ghost to my existing droplet where my website is running.

I’m using a droplet with ubuntu and Nginx. The website is running well. I’m running my website on port 3000 on a node server. Here is my sites-enabled default server block

server {
    listen          80;
    server_name     mydomain.io;
    return      301 http://www.mydomain.io$request_uri;
}

server {
    listen 80;

    server_name www.mydomain.io;

    location / {
        proxy_pass http://localhost:3000;
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection 'upgrade';
        proxy_set_header Host $host;
        proxy_cache_bypass $http_upgrade;
    }

    access_log /var/log/nginx/access.log;
    error_log  /var/log/nginx/error.log;
}

Here is my sites-enabled server block for the website.

server {
  listen       3000;
  server_name  mydomain.io;
  location / {
      root   /existing-website;
      index  index.html index.htm;
      auth_basic "Restricted";
      auth_basic_user_file /etc/nginx/.htpasswd; 
  }
}

I have downloaded and unzipped Ghost in /var/www/ghost, and installed with npm install --production. I have configured the Ghost production config to have the URL set to https://mydomain.io/blog and the port set to 1000

production: {
        url: 'https://www.mydomain.io/blog',
        mail: {},
        database: {
            client: 'sqlite3',
            connection: {
                filename: path.join(__dirname, '/content/data/ghost.db')
            },
            debug: false
        },

        server: {
            host: '127.0.0.1',
            port: '1000'
        }
    }

My most recent and promising attempt to get the blog running is to add the following section to the default (main) Nginx server block. I believe this should pass requests to mydomain.io/blog on to port 1000.

location /blog {
      proxy_set_header   X-Real-IP $remote_addr;
      proxy_set_header   HOST $http_host;
      proxy_set_header   X-NginX-Proxy true;
      proxy_pass         https://127.0.0.1:1000;
      proxy_redirect     off;
  }

When i restart nginx and run production

service nginx restart
npm start --production

I get the folliwing output:

> ghost@0.7.6 start /var/www/ghost
> node index

Migrations: Up to date at version 004
Ghost is running in production... 
Your blog is now available on https://www.mydomain.io/blog 
Ctrl+C to shut down

However, I cannot access it in the browser.

What can be wrong in my config here? Note: I’m using cloudflare to ‘supercharge’ my website. Could it cause trouble?

Thank you



This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Have spent ages on this issue - but when you are installing the blog as a subdomain on a website with the https protocol - the production json stays http WITHOUT https, i.e

production: {
        url: 'http://www.mydomain.io/blog',
        mail: {},
        database: {
            client: 'sqlite3',
            connection: {
                filename: path.join(__dirname, '/content/data/ghost.db')
            },
            debug: false
        },

        server: {
            host: '127.0.0.1',
            port: '1000'
        }
    }

I have CERTbot installed as per instructions in the this tutorial

The problem is fixed.

The code in the /blog location part was not working. When I simply duplicated the code block that was already there for my website it worked. The entire default config now looks like:


server {
    listen          80;
    server_name     mydomain.io;
    return      301 https://www.mydomain.io$request_uri;
}

server {
    listen 80;

    server_name www.mydomain.io;

    location / {
        proxy_pass http://localhost:3000;
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection 'upgrade';
        proxy_set_header Host $host;
        proxy_cache_bypass $http_upgrade;
    }

    location /blog {
        proxy_pass http://localhost:1000;
        proxy_http_version 1.1;
        proxy_set_header Update &http_upgrade;
        proxy_set_header Connection 'upgrade';
        proxy_set_header Host $host;
        proxy_cache_bypass $http_upgrade;
    }

    access_log /var/log/nginx/access.log;
    error_log  /var/log/nginx/error.log;
}


Did some research: Ghost experts say it is more appropriate to set the Ghost as ghost.mydomain.com for the existing website control by Ghost. Found great guidance: https://www.howtoforge.com/tutorial/ubuntu-nginx-ghost-blog/ Moreover (see the page) MariaDB is faster and lighter than mySQL, Google uses MariaDB.

The developer cloud

Scale up as you grow — whether you're running one virtual machine or ten thousand.

Get started for free

Sign up and get $200 in credit for your first 60 days with DigitalOcean.*

*This promotional offer applies to new accounts only.