Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to connect to a webserver on ec2 'privately'

I have a little web application deployed on an ec2 instance and I'd like to test it without making it publicly available.

Using an elastic IP does not solve my issue because the IP would then expose it to the outside world and we are not ready for this yet.

I'm aware of Amazon VPC but it seems a bit overkill since I don't need all those functionalities and I don't want to deal with the set up. All I need is to be able to hit the webserver by using a private IP or something like that.

Is there a quick and dirty solution for this?

like image 638
Marsellus Wallace Avatar asked Dec 16 '22 07:12

Marsellus Wallace


1 Answers

You could setup your web server to listen only on 127.0.0.1 (rather than 0.0.0.0) and then use SSH to tunnel a connection from your local machine to the instance.

From your desktop, setup the SSH connection:

$ ssh -L 3000:localhost:80 [email protected]

Then visit http://localhost:3000 in your browser and it will forward port 3000 on your desktop to port 80 on the instance, via the SSH connection.

like image 90
Greg Kempe Avatar answered Feb 13 '23 20:02

Greg Kempe