I am setting up a Ghost blog which works as a React-based SPA. Everything's hosted on DO.
That means I don't have a great way to tool around with Express, which is what powers Ghost.
For my frontend, I need to always serve my index response, regardless of the URL.
This is my nginx config now, with everything working except the SPA component.
server {
listen 443 ssl http2;
listen [::]:443 ssl http2;
server_name SITE;
root /var/www/ghost/system/nginx-root;
ssl_certificate /etc/letsencrypt/SITE/fullchain.cer;
ssl_certificate_key /etc/letsencrypt/SITE/SITE.key;
include /etc/nginx/snippets/ssl-params.conf;
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;
}
location ~ /.well-known {
allow all;
}
client_max_body_size 50m;
}
I've tried many of the existing answers here on setting up Nginx for SPAs with no success. For example, try_files $uri $uri/index.html =404;
Because I'm using proxy_pass
, am I limited to this sort of behavior in my Express app? That would not be ideal because editing the blog code will break my upgrades.