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


Submit an answer

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!

Sign In or Sign Up to Answer

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.

Want to learn more? Join the DigitalOcean Community!

Join our DigitalOcean community of over a million developers for free! Get help and share knowledge in Q&A, subscribe to topics of interest, and get courses and tools that will help you grow as a developer and scale your project or business.

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: