Connect to nodejs production app from another droplet within the same VPC via the private ip

Hello everyone, As I was following the tutorial for setting up a production-grade nodejs app on ubuntu 18.04, I came across some difficulties. Here is the link for the tutorial: Everything works great except that I have two nodejs apps running on two separate droplets within the same VPC. Both droplets are set the way following the tutorial link I mentioned above. I have two different domains. Each domain is pointed to each one of the droplets. The apps work individually as they should, meaning they can be reached out from their domain. The two droplets are supposed to talk to each other. Right now they can talk using the each other’s domain. But I want them to talk to each other using their private ip addresses since they are on the same VPC. When I run curl http://PRIVATE_IP_2 from droplet_1, the response comes from the app running on the droplet. But as soon as I add a path to it, nginx responds with its 404 default page content. Like curl http://PRIVATE_IP_2/api/internal would give me that nginx 404 page content and curl http://PRIVATE_IP_2 will return the app’s response. I really need your help make my work with external domain while they still communicate other the private network. Thank you


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.

Looks like communication across the VPC is working just fine.

If you want nginx to respond with the actual app you will need to add the private IP of each droplet into the nginx config of the app under the server heading:

server {
    listen       80;

Just replace with the private IP address of the droplet and it should work.