I want to create a website where few pages like
domainname.com, about, contact should be served by an express webserver & rest by ghost.
I am guessing I need to make some changes in nginx for this. Any idea how can I accomplish this? Currently I have default nginx configuration installed by ghost?
Hereβs an example:
server {
listen 443 ssl http2;
listen [::]:443 ssl http2;
server_name example.com;
location ~ /contact {
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:3000;
proxy_redirect off;
}
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:2368;
proxy_redirect off;
}
location ~ /.well-known {
allow all;
}
client_max_body_size 50m;
}
2 Likes
Solved this using http-middleware-proxy β GitHub - chimurai/http-proxy-middleware: The one-liner node.js http-proxy middleware for connect, express, next.js and more
Only directing / to express server and rest to ghost.
Live site β https://apmtools.io | Ghots pages β https://apmtools.io/getting-started/welcome
Installed ghost in root domain. nginx directing request to root domain on express server. Using http-proxy-middleware in express to proxy to ghost for non root pages