如何“私下"连接到 ec2 上的网络服务器 [英] How to connect to a webserver on ec2 'privately'

查看:32
本文介绍了如何“私下"连接到 ec2 上的网络服务器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 ec2 实例上部署了一个小型 Web 应用程序,我想对其进行测试,但不公开它.

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

使用弹性 IP 并不能解决我的问题,因为 IP 会将其暴露给外界,而我们还没有为此做好准备.

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.

我知道 Amazon VPC,但它似乎有点矫枉过正,因为我不需要所有这些功能,也不想处理设置.我所需要的只是能够通过使用私有 IP 或类似的东西来访问网络服务器.

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?

推荐答案

您可以将 Web 服务器设置为仅在 127.0.0.1(而不是 0.0.0.0)上侦听,然后使用 SSH 将连接从本地计算机建立到实例.

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.

在您的桌面上,设置 SSH 连接:

From your desktop, setup the SSH connection:

$ ssh -L 3000:localhost:80 ec2-user@ec2-instance.amazonaws.com

然后在浏览器中访问 http://localhost:3000,它将通过 SSH 连接将桌面上的端口 3000 转发到实例上的端口 80.

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.

这篇关于如何“私下"连接到 ec2 上的网络服务器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆