一、准备工作
前往https://ngrok.com/,下载ngrok ,然后注册一个账号,并获取官方分配一个授权令牌。
brew install ngrok #mac上执行命令安装ngrok,或在官网直接下载
二、本地绑定授权令牌
打开https://dashboard.ngrok.com/auth,复制你的授权令牌,执行如下操作:
ngrok authtoken 授权令牌

三、使用
1、下载之后直接解压得到 一个 ngrok 文件
2、直接终端运行
chmod a+x ngrok
即可修改权限。
3、开启服务
./ngrok http localhost:8080
或者
./ngrok http 8080
ngrok by @inconshreveable (Ctrl+C to quit)
Session Status online
Account Harry (Plan: Free)
Update update available (version 2.3.40, Ctrl-U to update)
Version 2.3.38
Region United States (us)
Web Interface http://127.0.0.1:4040
Forwarding http://4b735dffcb70.ngrok.io -> http://localhost:8080
Forwarding https://4b735dffcb70.ngrok.io -> http://localhost:8080
Connections ttl opn rt1 rt5 p50 p90
0 0 0.00 0.00 0.00 0.00
4、http、https服务器即可通过手机4G网络访问: http://4b735dffcb70.ngrok.io https://4b735dffcb70.ngrok.io
文章评论