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: [https://www.digitalocean.com/community/tutorials/how-to-set-up-a-node-js-application-for-production-on-ubuntu-18-04](http://). 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 droplet1, 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://PRIVATEIP2/api/internal would give me that nginx 404 page content and curl http://PRIVATEIP_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

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

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;
    server_name  example.org
                 www.example.org
                 192.168.1.1
                 ;
    ...
}

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

Submit an Answer