Question
Adding Ghost blog to existing website
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
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.
×