How to setup ghost with nginx configuration?

I have MERN stack app running with nginx configuration. I am planning to add /blog location block in nginx config and expose ghost blog for /blog location.

Nginx config:

location /blog {
       proxy_set_header Host $http_host;
       proxy_set_header X-Real-IP $remote_addr;
       proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

       proxy_pass http://localhost:2368;
}

Is this configuration ok? or do I need to add something else to make sure everything works and optimized? Any suggestions??

Almost…

2 Likes

Speed

1 Like

In both the articles I see this https://<yoursubdomain>.ghost.io; in my case I only want to enable ghost blog on /blog route so I can ignore https://<yoursubdomain>.ghost.io; subdomain part is that correct?

The second article does what you require, and the first is there for context.

Did you read the documentation?

    …
    location /blog/ {
        client_max_body_size 10G; # Required for uploading large files
    …
2 Likes

This solution worked for me:

location ^~ /blog {

                client_max_body_size 10G; # Required for uploading large files

                proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
                proxy_set_header Host $http_host;
                proxy_set_header X-Forwarded-Proto $scheme;
                proxy_pass http://127.0.0.1:2368;
        }

Note in config.production.json file:
replace "url":"http://localhost:2368/" with

"url": "https://yourapp.com/blog",

Some reference links:

  1. How install Ghost in a subfolder

  2. How to install Ghost in a subdirectory with Nginx? (Getting 404) - Stack Overflow