{"id":1805,"date":"2026-09-04T08:37:10","date_gmt":"2026-09-04T00:37:10","guid":{"rendered":"https:\/\/www.izhuhn.cn\/?p=1805"},"modified":"2026-09-04T08:37:10","modified_gmt":"2026-09-04T00:37:10","slug":"zi-jian-ngrok-mac-ke-hu-du-xiu-fu-jian-ji","status":"publish","type":"post","link":"https:\/\/www.izhuhn.cn\/index.php\/2026\/09\/04\/zi-jian-ngrok-mac-ke-hu-du-xiu-fu-jian-ji\/","title":{"rendered":"\u81ea\u5efa ngrok \u5185\u7f51\u7a7f\u900f Mac \u5ba2\u6237\u7aef\u4fee\u590d\u7b80\u8bb0"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">\u81ea\u5efa\u4e86\u4e00\u5957 ngrok 1.x \u5185\u7f51\u7a7f\u900f\u670d\u52a1\uff08\u670d\u52a1\u7aef ngrokd \u8dd1\u5728\u516c\u7f51\u670d\u52a1\u5668\u4e0a\uff09\uff0cMac \u5ba2\u6237\u7aef\u6b7b\u6d3b\u8dd1\u4e0d\u8d77\u6765\u3002\u672c\u6587\u8bb0\u5f55\u8fd9\u6b21\u6392\u67e5\u8e29\u8fc7\u7684\u56db\u4e2a\u5751\uff1a\u4e8c\u8fdb\u5236\u683c\u5f0f\u4e0d\u5bf9\u3001\u8001 Go \u7f16\u8bd1\u7684\u4e8c\u8fdb\u5236\u5728\u65b0 macOS \u4e0a\u5d29\u6e83\u3001\u65b0\u7248 Go \u62d2\u7edd\u65e0 SAN \u7684\u81ea\u7b7e\u8bc1\u4e66\u3001\u670d\u52a1\u7aef\u7aef\u53e3\u88ab\u522b\u7684\u4f1a\u8bdd\u5360\u7528\uff0c\u6700\u540e\u91cd\u65b0\u7f16\u8bd1\u3001\u6253\u8865\u4e01\u3001\u8dd1\u901a\u5168\u94fe\u8def\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">\u4e00\u3001\u5148\u9a8c\u683c\u5f0f\uff1afile \u662f\u6392\u969c\u7b2c\u4e00\u5200<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">\u73b0\u8c61\uff1a\u5ba2\u6237\u7aef\u4e00\u6267\u884c\u5c31\u62a5 <code>exec format error<\/code>\uff0c\u8fde\u7248\u672c\u53f7\u90fd\u6253\u4e0d\u51fa\u6765\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>$ file darwin_ngrok\ndarwin_ngrok: ELF 64-bit LSB executable, x86-64, dynamically linked, interpreter \/lib64\/ld-linux-x86-64.so.2<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">ELF \u662f Linux \u7684\u53ef\u6267\u884c\u683c\u5f0f\uff0cmacOS \u53ea\u8ba4 Mach-O\u3002\u6587\u4ef6\u540d\u53eb <code>darwin_ngrok<\/code> \u4e0d\u4ee3\u8868\u5b83\u5c31\u662f darwin \u4ea7\u7269\u2014\u2014\u5927\u6982\u7387\u662f\u7f16\u8bd1\u65f6\u7528\u4e86 <code>GOOS=linux<\/code>\uff08\u5f88\u591a\u6559\u7a0b\u524d\u534a\u6bb5\u5c31\u662f\u9519\u8bef\u793a\u8303\uff09\uff0c\u6216\u8005\u76f4\u63a5\u628a\u670d\u52a1\u5668\u4e0a\u7f16\u7684\u4ea7\u7269\u62f7\u4e86\u4e0b\u6765\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u6559\u8bad\uff1a\u8de8\u5e73\u53f0\u4e8c\u8fdb\u5236\u62ff\u5230\u624b\u5148 <code>file<\/code> \u9a8c\u683c\u5f0f\uff0c\u770b\u5230 <code>Mach-O 64-bit executable x86_64<\/code> \u624d\u662f Mac \u80fd\u8dd1\u7684\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">\u4e8c\u3001\u8001 Go \u7f16\u8bd1\u7684\u4e8c\u8fdb\u5236\u5728\u65b0 macOS \u4e0a\u76f4\u63a5\u5d29<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">\u6362\u4e86\u4e00\u4e2a Mach-O \u683c\u5f0f\u7684\u65e7\u5ba2\u6237\u7aef\uff082024 \u5e74\u7f16\u8bd1\u7684\uff09\uff0c\u4e00\u8fd0\u884c\u5c31\u5d29\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>failed MSpanList_Insert 0x888000 0x548c00eaae17 0x0\nfatal error: MSpanList_Insert<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">\u8fd9\u662f Go \u8fd0\u884c\u65f6\u5c42\u9762\u7684\u5d29\u6e83\u3002\u8fd9\u4e2a\u4e8c\u8fdb\u5236\u662f\u5f53\u5e74\u6309\u6559\u7a0b\u7528 Go 1.14.1 \u7f16\u8bd1\u7684\u2014\u2014\u8001 Go \u7684 runtime \u548c\u65b0\u7248 macOS \u4e0d\u517c\u5bb9\uff0c\u542f\u52a8\u9636\u6bb5\u521d\u59cb\u5316\u5185\u5b58\u5206\u914d\u5668\u5c31\u6302\u4e86\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u89e3\u51b3\uff1a\u88c5\u65b0 Go \u91cd\u7f16\u3002\u5b98\u7f51\u4e0b\u8f7d pkg \u5b89\u88c5\u5305\uff08\u6216\u8005 <code>brew install go<\/code>\uff09\uff0c\u88c5\u5b8c\u786e\u8ba4\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>$ go version\ngo version go1.26.4 darwin\/amd64<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">\u793a\u4f8b\u673a\u5668\u662f Intel Mac\uff0c\u6240\u4ee5 <code>GOARCH=amd64<\/code>\uff1bApple Silicon \u7528 <code>arm64<\/code>\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">\u4e09\u3001\u91cd\u65b0\u7f16\u8bd1\uff08GOPATH \u6a21\u5f0f\uff09<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">ngrok 1.x \u6e90\u7801\u662f GOPATH \u65f6\u4ee3\u7684\u9879\u76ee\uff08\u6ca1\u6709 go.mod\uff09\uff0c\u6e90\u7801\u6811\u672c\u8eab\u5c31\u662f\u4e2a GOPATH\uff1a<code>src\/<\/code> \u653e ngrok \u4e3b\u4ee3\u7801\u548c\u5168\u90e8\u4f9d\u8d56\uff0c<code>assets\/<\/code> \u91cc\u662f\u8bc1\u4e66\u8d44\u6e90\u3002\u5ba2\u6237\u7aef\u7f16\u8bd1\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>cd ~\/ngrok-authtoken\nGO111MODULE=off GOPATH=$PWD GOOS=darwin GOARCH=amd64 CGO_ENABLED=0 \\\n  go build -tags=release -o bin\/ngrok-darwin ngrok\/main\/ngrok<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">\u51e0\u4e2a\u8981\u70b9\uff1a<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><code>GO111MODULE=off<\/code> \u8d70 GOPATH \u6a21\u5f0f\uff0c\u4f9d\u8d56\u5168\u5728\u6e90\u7801\u6811\u91cc\uff0c\u4e0d\u7528\u8054\u7f51\u62c9\u5305\uff0c\u4e5f\u5c31\u4e0d\u53d7\u56fd\u5185\u7f51\u7edc\u5f71\u54cd<\/li>\n<li><code>-tags=release<\/code>\uff1a\u5d4c\u5165\u6b63\u5f0f\u8d44\u6e90\uff08\u5305\u62ec\u5185\u7f6e CA \u8bc1\u4e66\uff09\uff0c\u8d70\u6b63\u5f0f\u6784\u5efa\u5206\u652f\uff08\u4e0d\u5e26 release \u7684\u8c03\u8bd5\u6784\u5efa\u4f1a\u76f4\u63a5\u8df3\u8fc7\u8bc1\u4e66\u6821\u9a8c\uff09<\/li>\n<li><code>CGO_ENABLED=0<\/code> \u7eaf\u9759\u6001\u7f16\u8bd1\uff0c\u4e5f\u65b9\u4fbf\u4ee5\u540e\u4ea4\u53c9\u7f16\u8bd1<\/li>\n<li>\u5ba2\u6237\u7aef\u52a1\u5fc5\u7528\u548c\u670d\u52a1\u7aef\u540c\u4e00\u4efd\u6e90\u7801\u6811\u7f16\u8bd1\uff0c1.x \u8ba4\u8bc1\u63e1\u624b\u65f6\u4f1a\u6bd4\u5bf9\u534f\u8bae\u7248\u672c\uff0c\u7248\u672c\u4e0d\u4e00\u81f4\u76f4\u63a5\u88ab\u670d\u52a1\u7aef\u8e22<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">\u56db\u3001\u5751\uff1a\u65b0\u7248 Go \u62d2\u7edd\u65e0 SAN \u7684\u81ea\u7b7e\u8bc1\u4e66<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">\u7f16\u8bd1\u5b8c\u4e00\u8dd1\uff0c\u53c8\u62a5\u65b0\u9519\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>tls: failed to verify certificate: x509: certificate relies on legacy Common Name field, use SANs instead<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">\u539f\u56e0\uff1a\u81ea\u5efa ngrok \u670d\u52a1\u7aef\u4e00\u822c\u7528 openssl \u81ea\u7b7e\u8bc1\u4e66\uff0c\u53ea\u6709 CN\uff08Common Name\uff09\u6ca1\u6709 SAN\uff08Subject Alternative Name\uff09\u3002Go \u4ece 1.15 \u8d77\u5f31\u5316\u4e86 CN \u56de\u9000\uff0c\u65b0\u7248\u672c\u5e72\u8106\u76f4\u63a5\u62d2\u7edd\u65e0 SAN \u8bc1\u4e66\u2014\u2014\u54ea\u6015\u8fd9\u5f20\u8bc1\u4e66\u662f\u81ea\u7b7e\u540d\u7684\u3001\u800c\u4e14\u4f60\u5df2\u7ecf\u628a\u5b83\u5d4c\u8fdb\u4e86\u5ba2\u6237\u7aef\u7684\u4fe1\u4efb\u6c60\u3002\u5f53\u5e74 Go 1.14 \u80fd\u8dd1\u901a\uff0c\u9760\u7684\u6b63\u662f\u5f53\u65f6\u8fd8\u5b58\u5728\u7684 CN \u56de\u9000\uff0c\u5c5e\u4e8e\"\u80fd\u7528\u4f46\u8fc7\u65f6\"\u7684\u7ec4\u5408\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u5904\u7406\u6709\u4e24\u6761\u8def\uff1a<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u6b63\u8def\uff1a\u91cd\u7b7e\u4e00\u5f20\u5e26 SAN \u7684\u8bc1\u4e66\uff08<code>-addext &quot;subjectAltName=DNS:xxx.com,DNS:*.xxx.com&quot;<\/code>\uff09\uff0c\u670d\u52a1\u7aef\u6362\u8bc1\u4e66\u91cd\u542f\uff0c\u5ba2\u6237\u7aef\u6362\u5185\u7f6e CA \u91cd\u7f16\uff1b<\/li>\n<li>\u5feb\u8def\uff1a\u6539\u5ba2\u6237\u7aef\u6e90\u7801\uff0c\u628a Go 1.14 \u65f6\u4ee3\u7684\u6821\u9a8c\u884c\u4e3a\u52a0\u56de\u6765\u2014\u2014\u8bc1\u4e66\u94fe\u6821\u9a8c\u7167\u505a\uff08\u5bf9\u5185\u7f6e CA \u9a8c\u7b7e\uff09\uff0c\u4e3b\u673a\u540d\u6821\u9a8c\u5141\u8bb8\u5728 SAN \u4e4b\u5916\u56de\u9000\u5230 CN\u3002<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">\u6e90\u7801\u5728\u624b\uff0c\u9009\u4e86\u8def 2\uff0c\u6539\u4e24\u4e2a\u6587\u4ef6\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><code>src\/ngrok\/client\/tls.go<\/code> \u589e\u52a0\u4e00\u4e2a\u81ea\u6821\u9a8c\u56de\u8c03\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\/\/ cnFallbackVerifier \u8fd4\u56de\u4e00\u4e2a VerifyPeerCertificate\uff1a\u5b8c\u6574\u81ea\u505a\u8bc1\u4e66\u6821\u9a8c\u2014\u2014\n\/\/ \u8bc1\u4e66\u94fe\u5bf9\u7ed9\u5b9a roots \u9a8c\u7b7e\uff0c\u4e3b\u673a\u540d\u6309 SAN \u5339\u914d\u3001\u518d\u56de\u9000\u5230\u8001 Go 1.15 \u4e4b\u524d\u7684\n\/\/ CommonName \u5339\u914d\u3002\u65b0\u7248 Go \u5728\u81ea\u5df1\u7684\u6821\u9a8c\u9636\u6bb5\u5c31\u4f1a\u62d2\u7edd\u65e0 SAN \u8bc1\u4e66\n\/\/ \uff08\"legacy Common Name field\" \u9519\u8bef\uff09\uff0c\u6839\u672c\u8f6e\u4e0d\u5230\u8fd9\u4e2a\u56de\u8c03\uff0c\u6240\u4ee5\u5fc5\u987b\u914d\u5408\n\/\/ InsecureSkipVerify=true\uff0c\u628a\u5185\u7f6e\u6821\u9a8c\u6574\u4e2a\u5173\u6389\u3001\u7531\u8fd9\u4e2a\u56de\u8c03\u5168\u6743\u63a5\u7ba1\u3002\nfunc cnFallbackVerifier(hostname string, roots *x509.CertPool) func(rawCerts [][]byte, verifiedChains [][]*x509.Certificate) error {\n\treturn func(rawCerts [][]byte, verifiedChains [][]*x509.Certificate) error {\n\t\tif len(rawCerts) == 0 {\n\t\t\treturn errors.New(\"tls: no server certificate presented\")\n\t\t}\n\t\tleaf, err := x509.ParseCertificate(rawCerts[0])\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\tintermediates := x509.NewCertPool()\n\t\tfor _, raw := range rawCerts[1:] {\n\t\t\tif c, err := x509.ParseCertificate(raw); err == nil {\n\t\t\t\tintermediates.AddCert(c)\n\t\t\t}\n\t\t}\n\t\t\/\/ 1. \u8bc1\u4e66\u94fe\u6821\u9a8c\uff1a\u5bf9\u5185\u7f6e CA \u9a8c\u7b7e\uff08\u8fd9\u91cc\u4e0d\u505a\u4e3b\u673a\u540d\uff09\n\t\tif _, err := leaf.Verify(x509.VerifyOptions{\n\t\t\tRoots:         roots,\n\t\t\tIntermediates: intermediates,\n\t\t\tKeyUsages:     []x509.ExtKeyUsage{x509.ExtKeyUsageServerAuth},\n\t\t}); err != nil {\n\t\t\treturn err\n\t\t}\n\t\t\/\/ 2. \u4e3b\u673a\u540d\uff1a\u5148 SAN\uff0c\u518d CommonName \u515c\u5e95\n\t\tfor _, alt := range leaf.DNSNames {\n\t\t\tif dnsNameMatches(alt, hostname) {\n\t\t\t\treturn nil\n\t\t\t}\n\t\t}\n\t\tif leaf.Subject.CommonName != \"\" &amp;&amp;\n\t\t\tdnsNameMatches(leaf.Subject.CommonName, hostname) {\n\t\t\treturn nil\n\t\t}\n\t\treturn fmt.Errorf(\"x509: certificate is not valid for name %q\", hostname)\n\t}\n}\n\n\/\/ dnsNameMatches \u652f\u6301\u7cbe\u786e\u5339\u914d\u548c\u5355\u7ea7\u901a\u914d\u7b26\nfunc dnsNameMatches(pattern, name string) bool {\n\tpattern = strings.TrimSuffix(strings.ToLower(pattern), \".\")\n\tname = strings.TrimSuffix(strings.ToLower(name), \".\")\n\tif pattern == name {\n\t\treturn true\n\t}\n\tif strings.HasPrefix(pattern, \"*.\") {\n\t\tsuffix := pattern[2:]\n\t\tif strings.HasSuffix(name, \".\"+suffix) {\n\t\t\tlabel := strings.TrimSuffix(name, \".\"+suffix)\n\t\t\tif label != \"\" &amp;&amp; !strings.Contains(label, \".\") {\n\t\t\t\treturn true\n\t\t\t}\n\t\t}\n\t}\n\treturn false\n}<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\"><code>src\/ngrok\/client\/model.go<\/code> \u7684 TLS \u914d\u7f6e\u6bb5\u6539\u6210\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\t\/\/ configure TLS SNI\n\tm.tlsConfig.ServerName = serverName(m.serverAddr)\n\tif config.TrustHostRootCerts {\n\t\tm.tlsConfig.InsecureSkipVerify = useInsecureSkipVerify()\n\t} else {\n\t\t\/\/ \u81ea\u5efa\u670d\u52a1\u7aef\u5e38\u7528\u53ea\u6709 CN \u7684\u8001\u8bc1\u4e66\uff0c\u65b0\u7248 Go \u4f1a\u5728\u56de\u8c03\u4e4b\u524d\u5c31\u62d2\u7edd\u3002\n\t\t\/\/ \u5173\u95ed\u5185\u7f6e\u6821\u9a8c\uff0c\u94fe\u6821\u9a8c + \u4e3b\u673a\u540d\u5168\u90e8\u7531\u56de\u8c03\u5b8c\u6210\n\t\tm.tlsConfig.InsecureSkipVerify = true\n\t\tm.tlsConfig.VerifyPeerCertificate = cnFallbackVerifier(m.tlsConfig.ServerName, m.tlsConfig.RootCAs)\n\t}<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">\u8fd9\u91cc\u6709\u4e2a\u5b9e\u6d4b\u51fa\u6765\u7684\u5173\u952e\u7ec6\u8282\uff1a**\u53ea\u6302 <code>VerifyPeerCertificate<\/code> \u662f\u4e0d\u591f\u7684**\u3002\u65b0\u7248 Go \u5728\u8c03\u7528\u56de\u8c03\u4e4b\u524d\u5c31\u81ea\u5df1\u5b8c\u6210\u4e86\u4e3b\u673a\u540d\u6821\u9a8c\u5e76\u76f4\u63a5\u62a5\u9519\uff0c\u56de\u8c03\u6839\u672c\u6ca1\u673a\u4f1a\u6267\u884c\u3002\u5fc5\u987b\u540c\u65f6 <code>InsecureSkipVerify = true<\/code> \u628a\u5185\u7f6e\u6821\u9a8c\u6574\u4e2a\u5173\u6389\uff0c\u5728\u56de\u8c03\u91cc\u5b8c\u6574\u5730\u505a\u4e00\u904d\u3002\u8fd9\u6837\u5b89\u5168\u6027\u6ca1\u6709\u5012\u9000\uff1a\u4f9d\u7136\u8981\u6c42\u670d\u52a1\u7aef\u6301\u6709\u90a3\u5f20 CA \u7684\u79c1\u94a5\uff08\u94fe\u9a8c\u7b7e\u8fc7\u4e0d\u4e86\u5c31\u65ad\uff09\uff0c\u53ea\u662f\u4e3b\u673a\u540d\u5339\u914d\u6062\u590d\u4e86\u8001\u884c\u4e3a\u3002\u6539\u5b8c\u91cd\u7f16\uff0c\u8bc1\u4e66\u62a5\u9519\u6d88\u5931\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">\u4e94\u3001\u5ba2\u6237\u7aef\u914d\u7f6e\u4e0e\u7528\u6cd5\uff081.x \u8bed\u6cd5\u548c 2.x \u5b8c\u5168\u4e0d\u540c\uff09<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">\u914d\u7f6e\u6587\u4ef6\u662f**\u5355\u6587\u4ef6 <code>~\/.ngrok<\/code>**\uff081.x \u4e0d\u662f <code>~\/.ngrok2\/ngrok.yml<\/code>\uff09\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>server_addr: \"ngrok.example.com:93\"\nauth_token: \"\u4f60\u7684token\"\ntrust_host_root_certs: false\ntunnels:\n    mstsc:\n        subdomain: \"mstsc\"\n        remote_port: 19838\n        proto:\n            tcp: \"127.0.0.1:3389\"\n    t18789:\n        remote_port: 19840\n        proto:\n            tcp: \"127.0.0.1:18789\"<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">\u4e24\u4e2a\u6ce8\u610f\u70b9\uff1a<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u670d\u52a1\u7aef authtokens.txt \u6309\u76f8\u5bf9\u8def\u5f84\u4ece ngrokd \u7684\u5de5\u4f5c\u76ee\u5f55\u8bfb\u53d6\uff0c\u5ba2\u6237\u7aef auth_token \u5fc5\u987b\u548c\u670d\u52a1\u7aef\u6587\u4ef6\u91cc\u67d0\u4e00\u884c\u5b8c\u5168\u4e00\u81f4<\/li>\n<li>YAML \u5751\uff1atoken \u8fd9\u7c7b\u503c\u5982\u679c\u542b <code>*<\/code> \u7b49\u7279\u6b8a\u5b57\u7b26\u5fc5\u987b\u52a0\u5f15\u53f7\uff0c\u5426\u5219\u4f1a\u88ab\u5f53\u6210 YAML \u522b\u540d\u8282\u70b9\uff0c\u76f4\u63a5\u89e3\u6790\u62a5\u9519<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">1.x \u7684\u7528\u6cd5\u548c 2.x \u5dee\u5f02\u5f88\u5927\uff0c\u522b\u641e\u6df7\uff1a<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table>\n<thead><tr><th>\u64cd\u4f5c<\/th><th>2.x \u8bed\u6cd5<\/th><th>1.x \u8bed\u6cd5<\/th><\/tr><\/thead>\n<tbody>\n<tr><td>\u8d77\u4e00\u4e2a http \u96a7\u9053<\/td><td><code>ngrok http 8080<\/code><\/td><td><code>ngrok -proto=http 8080<\/code><\/td><\/tr>\n<tr><td>\u542f\u52a8\u914d\u7f6e\u91cc\u7684\u547d\u540d\u96a7\u9053<\/td><td>\u4e0d\u652f\u6301<\/td><td><code>ngrok start &lt;\u540d\u5b57&gt;<\/code><\/td><\/tr>\n<tr><td>\u542f\u52a8\u5168\u90e8\u547d\u540d\u96a7\u9053<\/td><td>\u4e0d\u652f\u6301<\/td><td><code>ngrok start-all<\/code><\/td><\/tr>\n<tr><td>flag \u4f4d\u7f6e<\/td><td>\u968f\u610f<\/td><td>\u5fc5\u987b\u5199\u5728\u4f4d\u7f6e\u53c2\u6570\u4e4b\u524d<\/td><\/tr>\n<\/tbody>\n<\/table><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">\u672c\u5730\u76d1\u63a7\u754c\u9762\u56fa\u5b9a\u5728 <code>http:\/\/127.0.0.1:4040<\/code>\uff0c\u53ef\u4ee5\u770b\u96a7\u9053\u72b6\u6001\u548c\u8bf7\u6c42\u8bb0\u5f55\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">\u516d\u3001\u5751\uff1a\u670d\u52a1\u7aef\u7aef\u53e3\u88ab\u522b\u7684\u4f1a\u8bdd\u5360\u7528<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">\u96a7\u9053\u6ce8\u518c\u65f6\u53c8\u62a5\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>Server failed to allocate tunnel: Error binding TCP listener: listen tcp 0.0.0.0:19838: bind: address already in use<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">\u8fd9\u4e0d\u662f\u5ba2\u6237\u7aef\u95ee\u9898\u2014\u2014ngrokd \u4f1a\u4e3a\u6bcf\u4e2a TCP \u96a7\u9053\u5728\u670d\u52a1\u7aef\u7ed1\u5b9a remote_port\uff0c\u800c\u670d\u52a1\u5668\u4e0a\u8fd8\u6709\u53e6\u4e00\u4e2a ngrok \u5ba2\u6237\u7aef\u4f1a\u8bdd\uff08\u53ef\u80fd\u662f\u53e6\u4e00\u53f0\u673a\u5668\u4e0a\u6302\u7740\u7684\u65e7\u5ba2\u6237\u7aef\uff09\u5360\u7740\u8fd9\u4e2a\u7aef\u53e3\u3002\u5230\u670d\u52a1\u5668\u4e0a <code>ss -tnp | grep 19838<\/code> \u627e\u5230\u8fde\u63a5\u6765\u6e90\uff0c\u628a\u65e7\u4f1a\u8bdd\u65ad\u6389\uff0c\u6216\u8005\u5e72\u8106\u6362\u4e2a\u7a7a\u95f2\u7aef\u53e3\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">\u4e03\u3001\u9a8c\u8bc1<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">\u6362\u4e00\u4e2a\u7a7a\u95f2\u7aef\u53e3\u505a\u7aef\u5230\u7aef\u9a8c\u8bc1\uff1a<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u5ba2\u6237\u7aef\u65e5\u5fd7\u51fa\u73b0 <code>Tunnel established at tcp:\/\/ngrok.example.com:19840<\/code><\/li>\n<li>\u672c\u5730\u76ee\u6807\u7aef\u53e3\u8d77\u4e2a\u56de\u663e\u670d\u52a1\uff0c\u4ece\u516c\u7f51 <code>nc<\/code> \u8fde\u670d\u52a1\u7aef\u7684 19840 \u7aef\u53e3\u53d1\u6570\u636e\uff0c\u672c\u5730\u6536\u5230\u3001\u539f\u8def\u8fd4\u56de\uff0c\u5168\u94fe\u8def\u901a<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">\u9700\u8981\u5e38\u9a7b\u7684\u8bdd\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>nohup .\/bin\/ngrok-darwin -log=stdout -log-level=INFO start t18789 &gt;&gt; ngrok.log 2&gt;&amp;1 &amp;<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">\u7b80\u8bb0<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">\u8fd9\u6b21\u4fee\u590d\u6a2a\u8de8\u4e09\u5c42\uff1a\u4e8c\u8fdb\u5236\u683c\u5f0f\uff08<code>file<\/code> \u4e00\u67e5\u4fbf\u77e5\uff09\u3001\u8fd0\u884c\u65f6\u517c\u5bb9\uff08\u8001 Go \u4e8c\u8fdb\u5236\u5728\u65b0 macOS \u4e0a\u542f\u52a8\u5373\u5d29\uff09\u3001TLS \u8bc1\u4e66\u7b56\u7565\u6f14\u8fdb\uff08Go 1.15 \u79fb\u9664 CN \u56de\u9000\uff0c\u65b0\u7248\u672c\u76f4\u63a5\u62d2\u7edd\u65e0 SAN \u8bc1\u4e66\uff09\u3002ngrok 1.x \u505c\u66f4\u591a\u5e74\uff0c\u5b98\u65b9 README \u81ea\u5df1\u90fd\u5199\u7740\u4e0d\u5efa\u8bae\u751f\u4ea7\u4f7f\u7528\uff0c\u4e34\u65f6\u7a7f\u900f\u591f\u7528\uff1b\u8981\u957f\u671f\u8dd1\u5efa\u8bae\u6362 2.x \u81ea\u5efa\u6216 frp\u3002\u4f46\"\u8001\u670d\u52a1 + \u65b0\u5de5\u5177\u94fe\"\u7684\u7ec4\u5408\u4f1a\u957f\u671f\u5b58\u5728\uff0c\u8fd9\u56db\u4e2a\u5751\u7b97\u662f\u628a\u7ec4\u5408\u62f3\u8e29\u4e86\u4e2a\u904d\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u81ea\u5efa\u4e86\u4e00\u5957 ngrok 1.x \u5185\u7f51\u7a7f\u900f\u670d\u52a1\uff08\u670d\u52a1\u7aef ngrokd \u8dd1\u5728\u516c\u7f51\u670d\u52a1\u5668\u4e0a\uff09\uff0cMac \u5ba2\u6237\u7aef\u6b7b\u6d3b\u8dd1\u4e0d\u8d77\u6765\u3002\u672c\u6587\u8bb0\u5f55\u8fd9\u6b21\u6392 &#8230;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[1],"tags":[],"class_list":["post-1805","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"jetpack_featured_media_url":"","jetpack-related-posts":[],"jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/www.izhuhn.cn\/index.php\/wp-json\/wp\/v2\/posts\/1805","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.izhuhn.cn\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.izhuhn.cn\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.izhuhn.cn\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.izhuhn.cn\/index.php\/wp-json\/wp\/v2\/comments?post=1805"}],"version-history":[{"count":1,"href":"https:\/\/www.izhuhn.cn\/index.php\/wp-json\/wp\/v2\/posts\/1805\/revisions"}],"predecessor-version":[{"id":1806,"href":"https:\/\/www.izhuhn.cn\/index.php\/wp-json\/wp\/v2\/posts\/1805\/revisions\/1806"}],"wp:attachment":[{"href":"https:\/\/www.izhuhn.cn\/index.php\/wp-json\/wp\/v2\/media?parent=1805"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.izhuhn.cn\/index.php\/wp-json\/wp\/v2\/categories?post=1805"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.izhuhn.cn\/index.php\/wp-json\/wp\/v2\/tags?post=1805"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}