本地機(jī)上有個(gè)網(wǎng)站,想讓外網(wǎng)的人訪問測試,又不想部署到外面服務(wù)上,開始想到使用“花生殼”,結(jié)果不支持Mac系統(tǒng)。
ngrok
找到一個(gè)據(jù)說能做內(nèi)網(wǎng)穿透的軟件,雖然看起來是國外的,不用自己服務(wù)的話,可能會慢啊,先試試吧!
下載解壓到指定目錄,執(zhí)行如下:
Chaim:tools Chaim$ ./ngrok
NAME:
ngrok - tunnel local ports to public URLs and inspect traffic
DESCRIPTION:
ngrok exposes local networked services behinds NATs and firewalls to the
public internet over a secure tunnel. Share local websites, build/test
webhook consumers and self-host personal services.
Detailed help for each command is available with 'ngrok help <command>'.
Open http://localhost:4040 for ngrok's web interface to inspect traffic.
EXAMPLES:
ngrok http 80 # secure public URL for port 80 web server
ngrok http -subdomain=baz 8080 # port 8080 available at baz.ngrok.io
ngrok http foo.dev:80 # tunnel to host:port instead of localhost
ngrok http https://localhost # expose a local https server
ngrok tcp 22 # tunnel arbitrary TCP traffic to port 22
ngrok tls -hostname=foo.com 443 # TLS traffic for foo.com to port 443
ngrok start foo bar baz # start tunnels from the configuration file
VERSION:
2.3.29
AUTHOR:
inconshreveable - <alan@ngrok.com>
COMMANDS:
authtoken save authtoken to configuration file
credits prints author and licensing information
http start an HTTP tunnel
start start tunnels by name from the configuration file
tcp start a TCP tunnel
tls start a TLS tunnel
update update ngrok to the latest version
version print the version string
help Shows a list of commands or help for one command
實(shí)際執(zhí)行如下:
Chaim:tools Chaim$ ./ngrok http 127.0.0.1:3000
ngrok by @inconshreveable (Ctrl+C to quit)
Session Status online
Session Expires 7 hours, 59 minutes
Version 2.3.29
Region United States (us)
Web Interface http://127.0.0.1:4040
Forwarding http://fd6562ef.ngrok.io -> http://127.0.0.1:3000
Forwarding https://fd6562ef.ngrok.io -> http://127.0.0.1:3000
Connections ttl opn rt1 rt5 p50 p90
0 0 0.00 0.00 0.00 0.00
在瀏覽器里訪問“http://fd6562ef.ngrok.io” 就可以訪問本地“http://127.0.0.1:3000” 了,不過的確很慢!這個(gè)域名每次啟動都會變,臨時(shí)用下還好,免費(fèi)的能要求啥呢!