I am trying to setup 2 web instances in a private network and put an internet facing load balancer infront of my two instances.
This is what i want to achieve:
The 2 private instance should be able to access resources on the internet. But the internet shouldn't be able to access the instances directly.
These 2 instances should only be accessible via port 80 from the load balancer from the internet.
The reason why i want to do this is because i don't want to expose these two servers on the internet.
- So i've created a VCN with CIDR block
10.15.0.0/16 - My two private subnets are
10.15.1.0/24and10.15.2.0/24respectively. - My public subnet is
10.15.100.0/24 - Instance A is hosted on private subnet1 and Instance B is hosted on private subnet 2
- My Network Load Balancer is hosted in the public subnet.
- I've added a route in my public subnet that routes
0.0.0.0/0traffic to my internet gateway - I've added a route in my private subnets that routes
0.0.0.0/0traffic to my NAT gateway
In the route table for subnet1 i have added a route to InstanceB
In the route table for subnet2 i have added a route to InstanceA
In the route table for public subnet i have added both a route to InstanceA and InstanceB
I have nginx hosted on both Instances.
From the instance i can ping 8.8.8.8 but from the outside i can't access the webpage using the load balancer's public IP.
A telnet to public_ip 80 works fine though. I tried to access the webpage from a browser and even did a curl but no success.
Is there something i did wrong ?
P.S i am doing these in OCI cloud