使用localtunnel 代替 ngrok 1.0 穿透内网服务

更换理由

  1. ngrok 最新版为2.x 但我们自己搭建服务只能用1.x
  2. ngrok 自建服务比较繁琐,虽然网上有很多好的教程
  3. 升级MacOS 到10.13,编译的客户端出现line 3: 4784 Segmentation fault: 11 解决不了......
  4. localtunnel 简单

使用localtunnel简单临时发布内网地址

➜  ~ npm install -g localtunnel
➜  ~ lt --port 8080
your url is: https://vsqgjucrti.localtunnel.me

使用命令行返回https://vsqgjucrti.localtunnel.me即可访问。

自己搭建更稳定的服务 localtunnel-server

安装

# pick a place where the files will live
git clone git://github.com/defunctzombie/localtunnel-server.git
cd localtunnel-server
npm install

# server set to run on port 1234
bin/server --port 1234

访问自己的服务

lt --host http://zhangdxchn.com:1234 --port 8080  --subdomain subdomin

注意这边有坑,host 参数对应不能写子域名否则报错Error: localtunnel server returned an error, please try again,使用subdomain 指定。
另外,我这边测试时二级以上子域名无法使用,二级域名限制:Subdomains must be lowercase and between 4 and 63 alphanumeric characters.

参考

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容