Question

Two Ghost instances running on server, one of them is Forbidden

Hi all,

I have a server with two domains pointed at it, serving two different websites. The first website is a simple Ghost blog, the second website is a home page with a subdirectory /log that is another Ghost blog.

The first installation works just fine. MySite.com leads to the blog, everything works as expected.

The second one is the issue. MyOtherSite.com leads to a landing page, and then MyOtherSite.com/log should lead you to the blog, but it’s showing a default nginx 403 page.

My sites-enabled looks like this:

server {
    listen 80;
    listen [::]:80;

    server_name MyOtherSite.com;
    root /var/www/MyOtherSite.com/log/system/nginx-root; # Used for acme.sh SSL verification (https://acme.sh)

    location ^~ / {
        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:2369;
        proxy_redirect off;
    }


    location ^~ /log {
        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:2369;
        proxy_redirect off;
    }

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

    client_max_body_size 50m;
}

The layout of the MyOtherSite.com is as follows:

-rw-r--r-- 1 www-data www-data  615 Sep 26 03:41 _index.html
-rw-r--r-- 1 root     root      250 Sep 27 07:52 index.html
drwxr-xr-x 4 phantom  phantom  4096 Sep 28 08:49 log
-rw-r--r-- 1 root     root      190 Sep 27 07:54 terrarium.css

Where phantom is my “ghost” user.


Submit an answer


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!

Sign In or Sign Up to Answer

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.

KFSys
Site Moderator
Site Moderator badge
January 23, 2023

Hi @willrobert,

First, should the proxy_pass lead to the same port? Is it possible for two ghost instances to use the same port, in your case 2369?

Additionally, locations are evaluated in this order:

  1. location = /path/file.ext {} Exact match
  2. location ^~ /path/ {} Priority prefix match -> longest first
  3. location ~ /Paths?/ {} (case-sensitive regexp) and location ~* /paths?/ {} (case-insensitive regexp) -> first match
  4. location /path/ {} Prefix match -> longest first

Try DigitalOcean for free

Click below to sign up and get $200 of credit to try our products over 60 days!

Sign up