Ramesh
Ramesh

Reputation: 775

Connect to a web application in private through bastion host for my local machine in aws

I have an EC2 instance running in AWS and here's the scenario I'm trying to achieve. I have a VPC setup with 3 subnets. 2 of them are private with no access to the internet (even using a NAT gateway/NAT instance), and another is a public subnet.

If I set up the SSH connection as discussed here, it works perfectly fine for the web browser page set up on my bastion host. However, for my use case, I need to achieve another level of SSH forward like above as my application is in the private subnet for that application to be accessible from my local machine. Is that possible somehow? I also need to make sure there are no issues with the DNS.

Upvotes: 0

Views: 5320

Answers (2)

Mohammad Ghonaim
Mohammad Ghonaim

Reputation: 434

ssh -N <Bastion_IP/HostName> -L<LocalPort>:<Internal_IP_of_Web_Server>:<WebServer_Port>

Then you can access the webserver http://localhost:<LocalPort>/

Upvotes: 7

Victor
Victor

Reputation: 484

Assuming you have a web application on ec2 in a private subnet and you want to make it available for access outside AWS.

You can setup port forwarding on your bastion host following this tutorial, but I suggest you use a load balancer (ELB) as described in this guide. To use an ELB you will need another public subnet in a different AZ. If you're application is serving HTTP traffic, then it's even better to use a Application ELB (ALB). Here is more info about ALB.

Upvotes: 1

Related Questions