目录

ngrok基本使用

Ngrok 是一个反向代理软件,启动后会在公共服务器和本地客户端之间建立一个通道,并由公共服务器分配一个唯一的域名给这个通道。在 Homestead 中运行 Ngrok 之后,通过公共服务器分配的域名就可以在公网访问到 Homestead 中的站点,从而让支付宝和微信支付的服务器直接将回调数据发送到对应的回调接口。

一、Unzip to install

On Linux or Mac OS X you can unzip ngrok from a terminal with the following command. On Windows, just double click ngrok.zip to extract it.

1
2
$ unzip ngrok-stable-darwin-amd64.zip ngrok
$ mv ngrok /usr/local/bin

二、Connect your account

Running this command will add your authtoken to the default ngrok.yml configuration file. This will grant you access to more features and longer session times. Running tunnels will be listed on the status page of the dashboard.

1
2
# 新打开一个终端
$ ngrok authtoken 你自己的凭证

三、Fire it up

Read the documentation on how to use ngrok. Try it out by running it from the command line:

1
$  ./ngrok help

To start a HTTP tunnel forwarding to your local port 80, run this next:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
$ ./ngrok http 80
ngrok by @inconshreveable                                                                                                                                                 (Ctrl+C to quit)

Session Status                online
Account                       david (Plan: Free)
Version                       2.3.35
Region                        United States (us)
Web Interface                 http://127.0.0.1:4040
Forwarding                    http://9b3d079e2927.ngrok.io -> http://localhost:80
Forwarding                    https://9b3d079e2927.ngrok.io -> http://localhost:80

Connections                   ttl     opn     rt1     rt5     p50     p90
                              0       0       0.00    0.00    0.00    0.00

Next, check out some tutorials

We’ve written tutorials to guide you through common use cases like developing on chatbots, setting up SSH access to IoT devices or testing on mobile devices.

Check Out Tutorials