编译安装
编译生成ngrok的windows客户端:
- GOOS=windows GOARCH=amd64 make release-client
把编译生成的ngrok.exe 拷到windows电脑上,
在windows上新建一个ngrok.cfg
- server_addr: "test.com:7443"
- trust_host_root_certs: false
在windows上建立一个startup.bat
- ngrok -config=ngrok.cfg -subdomain 映射本地的域名 本地的端口
如ngrok -config=ngrok.cfg -subdomain t1 8081
现在文件结构是这样的:
“`
使用
启动start.bat,
外网域名访问
http://t1.test.com:8234
映射到本地的地址是
http://127.0.0.1:8081
一个复杂的配置文件示例:
- server_addr: "myngrok.com:8083"
- trust_host_root_certs: false
-
- tunnels: http: subdomain: "www" proto: http: "8081" https: subdomain: "www" proto: https: "8082" web: proto: http: "8050" tcp: proto: tcp: "8001" remote_port: 5555 ssh: remote_port: 2222 proto: tcp: "22"
一个可以自动启动子域名的bat
- @echo OFF
- color 0a
- Title ngrok启动
- Mode con cols=109 lines=30
- :START
- ECHO.
- Echo ==========================================================================
- ECHO.
- Echo ngrok启动
- ECHO.
- Echo 作者: https://segmentfault.com/u/object
- ECHO.
- Echo ==========================================================================
- Echo.
- echo.
- echo.
- :TUNNEL
- Echo 输入需要启动的域名前缀,如“test” ,即分配给你的穿透域名为:“test.myngrok.com”
- ECHO.
- ECHO.
- ECHO.
- set /p clientid= 请输入:
- echo.
- ngrok -config=ngrok.cfg -subdomain=%clientid% 80
- PAUSE
- goto TUNNEL