Min
Min

Reputation: 538

Port forwarding on AWS from the internet to private subnet instance

Is there a way to open server (instance) on private subnet on AWS that can be reached from the internet? It seems AWS has NAT instance but I was not able to find a way to set rule to forward to specific machine if request comes to a certain port.

Upvotes: 0

Views: 3363

Answers (2)

John Rotenstein
John Rotenstein

Reputation: 269101

No, you (intentionally) cannot reach an instance in a private subnet.

One option is to launch a "Bastion Server" in a public subnet, then use SSH port forwarding so that a port on the private instance is magically attached to your local computer.

Example:

ssh -i KEYPAIR.pem -L 8000:PRIVATE-INSTANCE-IP:8000 ec2-user@EC2-IP-ADDRESS

This is actually just normal Linux stuff -- it is nothing specific to Amazon EC2.

Upvotes: 2

Quentin Revel
Quentin Revel

Reputation: 1478

You should use a Load Balancer for that.

The load balancer will be public facing and will forward requests to your private instance.

Upvotes: 2

Related Questions