Question

Run express and ghost on same droplet

Hi, I have a node js application running on a droplet under deskrive.com, I want to have a ghost blog on the same droplet under deskrive.com/blog, and configure nginx reverse proxy to use this different subdomains. How can I accomplish this? Thanks

Subscribe
Share

Submit an answer
You can type!ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

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.

In order to serve both sites from the same Droplet, you will need to configure both the Express app and Ghost to listen on separate port with Nginx directing request to the correct destination.

You Nginx config would look something like:

server {
    listen       80;
    server_name  localhost;

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

        proxy_pass http://127.0.0.1:3000;
        proxy_redirect off;
    }

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

        proxy_pass http://127.0.0.1:2368;
        proxy_redirect off;
    }
}

For more information, check out these tutorials: