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

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.

×
1 answer

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:

by Brennen Bearnes
Node.js is an open source JavaScript runtime environment for easily building server-side and networking applications. Node.js applications can be run at the command line but this guide focuses on running them as a service using PM2, so that they will automatically restart on reboot or failure, and can safely be used in a production environment.
Submit an Answer