By smoudou
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. 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
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!
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.
Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.
Full documentation for every DigitalOcean product.
The Wave has everything you need to know about building a business, from raising funding to marketing your product.
Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.
New accounts only. By submitting your email you agree to our Privacy Policy
Scale up as you grow — whether you're running one virtual machine or ten thousand.
Sign up and get $200 in credit for your first 60 days with DigitalOcean.*
*This promotional offer applies to new accounts only.