I am going to deploy Nginx webserver to run my angular application in AWS ec2 and i have 2 subnets public and private. to reach my nginx web application I will use ALB which is in public subnet, now my question is
- can i deploy the Nginx webserver(ec2) in private subnet.
- in which case I should enable public IP to my nginx ec2 server
CodePudding user response:
You should not assign a public IP address to the nginx EC2 server because:
- It should only be accessed via the Load Balancer, and
- It is in a private subnet, so the Public IP address will not work (that is, traffic will not be routed to the instance)
You should deploy the Load Balancer in the public subnet and the EC2 instance in the private subnet.
CodePudding user response:
can i deploy the Nginx webserver(ec2) in private subnet.
Yes, you can. In ideal case the private webserver does not need any internet access.
in which case I should enable public IP to my nginx ec2 server
The server does not require public IP. If you place it in a private subnet, and you want your server to access internet (e.g. to install packages or updates) you have to setup NAT gateway in a public subnet.