I have two windows Serer 2016 web servers in the public subnets:
- Each web server have their own public IP addresses.
- Each web server has self-signed SSL certificate, has both HTTP and HTTPS bindings, and redirecting HTTP to HTTPS.
- They are in a Target Group. There is an Application Load Balancer using that Target Group.
I could request the pages from the web servers directly or from the ELBs. Response is instant. All good.
Once I removed the public IP addresses from the web servers, the response from the ELB becomes very unreliable. It times out every now and then with error 504 Gateway Timeout. But sometimes it does work.
Why?
A cheaper solution than a NAT gateway is an S3 Endpoint. From that page
This means you don't have to pay for a NAT gateway, just traffic to S3. Note that
With the help of Mike, Ben and Appleoddity I finally figured out. The web servers does need traffic to outside because they are access AWS S3. They stop functioning as soon as their public IPs are removed, because they need it to connect to the Internet. The proper implementation that maximums the security is to place the web servers in the private subnets, and add a NAT gateway to each corresponding public subnet, and add a route in the route table to route traffic to 0.0.0.0/0 to the NAT gateway.