How to set up website on the main url and Ghost on /blog?

  • What’s your URL? http://wishpy.com/
  • What version of Ghost are you using? Latest
  • How was Ghost installed and configured? With Digital Ocean Marketplace one-click button
  • What Node version, database, OS & browser are you using? Node 12.18.0, Mac, Chrome

Hey,
how do you put simple index.html at the root of the domain? My Ghost is installed in the /blog directory http://wishpy.com/blog and works fine. I’d like to have some landing page on https://wishpy.com/. I’ve tried to replace index.html file in /var/www/html where previously was nginx starting page with my own index.html, but I started to receive 403 forbidden after this.

2021/03/21 06:01:58 [error] 32181#32181: *146 directory index of "/var/www/ghost/system/nginx-root/" is forbidden, client: 145.14.240.221, server: wishpy.com, request: "GET / HTTP/2.0", host: "wishpy.com"

2021/03/21 06:01:59 [error] 32181#32181: *146 open() "/var/www/ghost/system/nginx-root/favicon.ico" failed (2: No such file or directory), client: 145.14.240.221, server: wishpy.com, request: "GET /favicon.ico HTTP/2.0", host: "wishpy.com", referrer: "https://wishpy.com/"

2021/03/21 06:02:12 [error] 32181#32181: *148 open() "/var/www/ghost/system/nginx-root/favicon.ico" failed (2: No such file or directory), client: 145.14.240.221, server: wishpy.com, request: "GET /favicon.ico HTTP/1.1", host: "wishpy.com", referrer: "http://wishpy.com/blog/"

2021/03/21 06:04:38 [error] 32181#32181: *156 open() "/var/www/ghost/system/nginx-root/favicon.ico" failed (2: No such file or directory), client: 145.14.240.221, server: wishpy.com, request: "GET /favicon.ico HTTP/1.1", host: "wishpy.com", referrer: "http://wishpy.com/blog/"
1 Like

You’ll want to update your nginx config to look like this (a majority of this should already exist, the updated part is location / { ... }; anything in <% ... %> should be updated):

server {
    listen 443 ssl http2;
    listen [::]:443 ssl http2;

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

    ssl_certificate <%= fullchain %>;
    ssl_certificate_key <%= privkey %>;
    include <%= sslparams %>;

    location / {
        root /var/www/html;
        try_files $uri $uri/ =404;
    }

    location /blog {
        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:<%= port %>;
        proxy_redirect off;
    }

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

    client_max_body_size 50m;
}

Once you’ve updated, run sudo nginx -s reload to safely reload your nginx config.

3 Likes

Works like a charm. Thank you very much!

2 Likes