4

如何通过隧道将本地主机连接到公共互联网上 - Vlad Mihalcea

 2 years ago
source link: https://www.jdon.com/57936
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

如何通过隧道将本地主机连接到公共互联网上 - Vlad Mihalcea

在本文中,我将向您展示如何通过隧道将本地主机环境连接到公共 Internet 地址,您用于测试的其他服务可以访问该地址。

在网络中,隧道允许您将数据包从专用网络传输到公共网络。例如,隧道与 VPN(虚拟专用网络)一起使用以保护网络连接。

Linux的ssh端口转发还使用了另一个网络隧道示例,它允许您将数据包从本地主机环境安全地传输到公共网络。

虽然创建网络隧道的方法有很多,但我最喜欢的工具是Ngrok。下载该工具后,我创建了一个tunnel.bat可在 Windows PATH 上使用的脚本:

@echo off 
call ngrok http %*

要打开 HTTP 或 HTTPS 隧道,我所要做的就是运行以下命令:

>tunnel 8080
 
ngrok by @inconshreveable
 
Session Status  online
Version         2.3.40
Region          United States (us)
Web Interface   http://127.0.0.1:4040
Forwarding      http‎://‎956e-188-24-86-235.ngrok‎.io 🡒 http://localhost:8080
Forwarding      https‎:/‎/956e-188-24-86-235.ngrok‎.io 🡒‎ http://localhost:808
 
Connections     ttl     opn     rt1     rt5     p50     p90
                0       0       0.00    0.00    0.00    0.00

现在,localhost:8080可在246d-188-24-86-235.ngrok.io‎地址供访问,也就是说246d-188-24-86-235.ngrok.io‎使用到我的本地主机环境的 HTTPS 隧道。

为了测试前端的性能,我现在可以使用 GT Metrix 来分析在我的 localhost 环境中运行的 Spring Boot 服务器。


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK