Report this

What is the reason for this report?

Run express and ghost on same droplet

Posted on October 10, 2017

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



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!

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:

The developer cloud

Scale up as you grow — whether you're running one virtual machine or ten thousand.

Get started for free

Sign up and get $200 in credit for your first 60 days with DigitalOcean.*

*This promotional offer applies to new accounts only.