Ghost as a sub directory using NGINX


I would like my ghost blog to be served from instead of the root.

I followed a tutorial found here:
but cannot get it working.

btw, ghost does work when I make it the root, So I believe my installation is correct and that I am just having problems using it as a subdirectory.

Here is my block in my NGINX config file.

location ^~ /blog/ {
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_set_header X-NginX-Proxy true;
proxy_pass http://localhost:2368;
proxy_redirect off;

Here is my ghost config file

"database": {
    "client": "sqlite3",
    "connection": {
        "filename": "content/data/ghost-dev.db"
    "debug": false
"server": {
    "host": "",
    "port": "2368"
"paths": {
  "contentPath": "./content"

After restarting Ghost, it says "INFO Url configured as:
However, I get a 404 Page Not Found page when navigating to /blog. The sample posts are present on the page though without any images or CSS.

Any ideas on possible fixes?

Hi there,

Is there a reason you aren’t using Ghost-CLI? It would sort this configuration out for you automatically.

The tutorial you followed doesn’t have the trailing slash for the location match.

In the templates used by Ghost-CLI (which you can find in the repo via the cli docs the location is specified exactly rather than using the caret-tilde match:

location /blog/ {
   // config here

Not 100% sure if this is the cause though - it could be some other part of the file is causing a conflict.

1 Like

Just made the change, but still no luck.

If I use the Ghost-CLI can I still use a sqlite database? Also, I already have a NGINX config file for the rest of my site. So will the ghost populated NGINX files overwrite, or cause any issues with the existing config file?

Yes of course, the options for ghost install are documented here:

The CLI will create entirely new, separate files, as per the templates I linked to above & then will symlink those into place in /etc/nginx/sites-enabled/. No existing files will be touched.

If there is some configuration elsewhere in your nginx config that “trumps” or conflicts with the Ghost config, it could definitely still cause trouble. Undoing that would be a case of removing the added symlinks and restarting nginx. Our templates deliberately do not use the default_server directive, which reduces most opportunity for conflict.

Hi there,
@belltyler How did it go? Were you successful to run your blog via subdirectory?

I’ll be installing Ghost in my blog folder tonight,, using CLI. Let’s see how it goes. I’ll be calling you @Hannah if ran into trouble. My stack is slightly different but supported. I am using Ubuntu 18.04, SQLite3, and Node8 (LTS).

Yes! Using the CLI resolved the issue. I ended up taking the nginx config file it created, and copying it over to my main nginx config file. Worked perfectly.

Hi there,

I have successfully installed ghost in my subdirectory However ghost admin panel at is gone 404. Could you please guide me what’s going wrong with admin panel? How can I enable it and start writing?

Thank you.

If you’ve installed Ghost in a subdirectory then your admin panel would live at

1 Like

I am really sorry for the embarrassment Kevin, I am really sorry.

Don’t be sorry, sometimes no matter how long you look at things it just doesn’t click, we’ve all been there :smile:

1 Like

So true, Kevin. :smile:

It was really a joy to install Ghost on a subdomain then in a subdirectory. I feel stronger than before now. All the great help came from Ghost documentation.


This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.