Ghost nginx 404 error - running alongside express server

Hello, I have a website running on an express server and am trying to add a blog to it at website.com/blog.

I’ve been trying for 2 days to get ghost up and running, but am still stuck with an nginx 404. I know something must be wrong with my configuration.

My /etc/nginx/sites-available/default file is as follows:

server {
root /var/www/vector-training-academy;

index index.html index.htm index.nginx-debian.html;

server_name www.website.com website.com;

location / {
	proxy_pass http://localhost:3001;
}

location /blog/ {
	root /var/www/vector-training-academy/ghost;
	try_files $uri $uri/ =404;
    	proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    	proxy_set_header X-Forwarded-Proto $scheme;
    	proxy_set_header X-Real-IP $remote_addr;
    	proxy_set_header Host $http_host;
    	proxy_pass http://127.0.0.1:2368;        
}

 location ~ /.well-known {
    	allow all;
	}

listen [::]:443 ssl; # managed by Certbot
listen 443 ssl; # managed by Certbot
ssl_certificate /etc/letsencrypt/live/website.com-0003/fullchain.pem; # managed by Certbot
ssl_certificate_key /etc/letsencrypt/live/vwebsite.com-0003/privkey.pem; # managed by Certbot
include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot

}

server {

root /var/www/vector-training-academy;

index index.html index.htm index.nginx-debian.html;
# managed by Certbot


location / {
	proxy_pass http://localhost:3001/;
}	

}

server {
if ($host = www.example.com) {
return 301 https://$host$request_uri;
} # managed by Certbot

if ($host ~ ^[^.]+\.example\.com$) {
    return 301 https://$host$request_uri;
} # managed by Certbot

if ($host = example.com=) {
    return 301 https://$host$request_uri;
} # managed by Certbot

listen 80 default_server;
listen [::]:80 default_server;

server_name example.com www.example.com
return 404; # managed by Certbot

}

My config file is:

{
“url”: “http://www.website.com/blog”,
“server”: {
“port”: 2368,
“host”: “127.0.0.1”
},
“database”: {
“client”: “mysql”,
“connection”: {
“host”: “localhost”,
“user”: “ghost-586”,
“password”: “GsZhK}7m+)+:PX}!]EXF”,
“database”: “vector_blog”
}
},
“mail”: {
“transport”: “Direct”
},
“logging”: {
“transports”: [
“file”,
“stdout”
]
},
“process”: “systemd”,
“paths”: {
“contentPath”: “/var/www/vector-training-academy/ghost/content”
}
}

Lastly on my express server.js I am listening on both ports:

//Start server
app.listen(process.env.PORT || 3001, function () {
console.log("Listening on port " + process.env.PORT);
});

//ghost server
const ghost = express();
ghost.listen(2367, function() {
console.log(“Ghost listening on 2367”)
}))

Any advice would be greatly appreciated!

This seems out of place for a route that’s proxied :thinking:

That fixed it! Thank you SO much…I was really stuck on this.

1 Like