Mac 安装使用 Ngrok

下载安装

  1. 访问 Ngrok 官网:https://dashboard.ngrok.com/get-started,并注册或使用第三方登录。
  2. 点击解压后,将 ngrok 拖拽到应用程序目录。
    Mac 中移动完成后程序目录为 /Applications/ngrok

建立 Ngrok 软连接

~ cd /usr/local/bin
~ ln -s /Applications/ngrok ngrok

创建之后,可以在任意地方使用 ngrok 命令。

配置 authtoken

  1. 从官网上复制自己的 authtoken,如图
  2. 在本地命令行任意位置运行
    ~ ngrok authtoken yourself-token
    Authtoken saved to configuration file: /Users/User/.ngrok2/ngrok.yml

配置 ngrok.yml 文件。

使用 Ngrok

在本地命令行任意目录执行

~ ngrok http -host-header=shop.test -region us 80

ngrok by @inconshreveable                                               (Ctrl+C to quit)

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

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

详细文档地址https://ngrok.com/docs

本作品采用《CC 协议》,转载必须注明作者和本文链接
《L03 构架 API 服务器》
你将学到如 RESTFul 设计风格、PostMan 的使用、OAuth 流程,JWT 概念及使用 和 API 开发相关的进阶知识。
《L01 基础入门》
我们将带你从零开发一个项目并部署到线上,本课程教授 Web 开发中专业、实用的技能,如 Git 工作流、Laravel Mix 前端工作流等。
讨论数量: 4

执行这个 ngrok http -host-header=shop.test -region us 4000 卡住不动了

6年前 评论

@lovecn 卡住不动?你有程序运行在4000吗

6年前 评论
6年前 评论
alalala (楼主) 6年前

我的是自己搭建在自己服务器上

6年前 评论

讨论应以学习和精进为目的。请勿发布不友善或者负能量的内容,与人为善,比聪明更重要!