WordPress – NAT gateway set up doesn’t work

amazon-nat-gatewayamazon-web-servicesWordpress

I have implemented an environment for a WordPress website. I have a loadbalncer (ALB) that is connected to an EC2 server plus an AutoScaling group(for failover).

As we need to update WordPress and install some plugins on EC2 server, I need to set up NAT gateway to allow internet connection from wordpress server(ec2) to internet.

I have set up the NAT gateway like the following link:
https://aws.amazon.com/premiumsupport/knowledge-center/nat-gateway-vpc-private-subnet/

However I could not be able to reach the Website (DNS of ALB) afterward.

My Routetable set up looks like below:

                      Route                Subnets
Main Route Table        10.0.0.0/16 local       -
                     0.0.0.0/0   natgw

Public Route Table        10.0.0.0/16 local       10.0.10.0/24, 10.0.11.0/24  (ELB subnets)
                     0.0.0.0/0   igw

Private route B      10.0.0.0/16 local       10.0.20.0/24,10.0.30.0/24 (EC2 subnets)
                     0.0.0.0/0   natgw  

Private route C      10.0.0.0/16 local       10.0.21.0/24,10.0.31.0/24 (RDS subnets)
                     0.0.0.0/0   natgw

The Public route is assigned to two public subnets which are connected to the LoadBalancer.

The Private route B,C are assigned to private subnets: Web server()EC2 plus database-RDS.

Any help would be appreciated.

enter image description here

Best Answer

Your diagram shows the IGW subnets do not overlap with your NAT Gateway subnets. This is the issue. The NAT Gateway needs to be in a subnet with an attached IGW. This is true even though the NAT Gateway has a public ip (Elastic IP).

Related Topic