-
-
Save jingmian/05ead8b6a2f24e265852aa457c5587a4 to your computer and use it in GitHub Desktop.
ngrok安装
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| https://github.com/sunnyos/ngrok | |
| ngrok一键安装脚本,适用于Centos版本服务器 | |
| 默认安装路径 | |
| git:/usr/local/git | |
| go:/usr/local/go | |
| ngrok:/usr/local/ngrok | |
| #使用说明: chmod +x ngrok.sh | |
| sh ./ngrok.sh | |
| 进行选择,安装 | |
| 在服务器的nginx为了不和ngrok端口80冲突,需要设置nginx配置文件 | |
| server { | |
| listen 80 ; | |
| server_name *.ngrok.XXXX.com; | |
| location / { | |
| proxy_set_header X-Real-IP $remote_addr; | |
| proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; | |
| proxy_set_header Host $http_host:8000; | |
| proxy_set_header X-Nginx-Proxy true; | |
| proxy_set_header Connection ""; | |
| proxy_pass http://127.0.0.1:8000; | |
| } | |
| } | |
| 服务器启动ngrok | |
| ./bin/ngrokd -domain="ngrok.phpvue.com" -httpAddr=":8000" -tlsKey="/usr/local/src/ngrok/2_test.ngrok.phpvue.com.key" -tlsCrt="/usr/local/src/ngrok/1_test.ngrok.phpvue.com_bundle.crt" | |
| ****************ngrok.cfg************************ | |
| server_addr: "test.ngrok.phpvue.com:4443" | |
| trust_host_root_certs: true | |
| tunnels: | |
| test: | |
| proto: | |
| https: "443" | |
| http: "80" | |
| web2: | |
| proto: | |
| tcp: "22" | |
| ***************************** | |
| 客户端启动 | |
| ./ngrok -config=./ngrok.cfg start test | |
| ===========================本地nginx设置========================= | |
| server | |
| { | |
| listen 80; | |
| listen 443; | |
| #listen 443 ssl http2; | |
| #listen [::]:80; | |
| server_name test.ngrok.phpvue.com ; | |
| index index.html index.htm index.php default.html default.htm default.php; | |
| #ssl on; | |
| ssl_certificate /usr/local/nginx/conf/ssl/test.ngrok/1_test.ngrok.phpvue.com_bundle.crt; | |
| ssl_certificate_key /usr/local/nginx/conf/ssl/test.ngrok/2_test.ngrok.phpvue.com.key; | |
| ssl_session_timeout 5m; | |
| ssl_protocols TLSv1 TLSv1.1 TLSv1.2; | |
| ssl_prefer_server_ciphers on; | |
| ssl_ciphers "EECDH+CHACHA20:EECDH+CHACHA20-draft:EECDH+AES128:RSA+AES128:EECDH+AES256:RSA+AES256:EECDH+3DES:RSA+3DES:!MD5"; | |
| ssl_session_cache builtin:1000 shared:SSL:10m; | |
| root /home/wwwroot/ngrok.phpvue.com; | |
| include rewrite/none.conf; | |
| #error_page 404 /404.html; | |
| # Deny access to PHP files in specific directory | |
| #location ~ /(wp-content|uploads|wp-includes|images)/.*\.php$ { deny all; } | |
| include enable-php-pathinfo.conf; | |
| location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$ | |
| { | |
| expires 30d; | |
| } | |
| location ~ .*\.(js|css)?$ | |
| { | |
| expires 12h; | |
| } | |
| location ~ /.well-known { | |
| allow all; | |
| } | |
| location ~ /\. | |
| { | |
| deny all; | |
| } | |
| access_log /home/wwwlogs/ngrok.phpvue.com.log; | |
| } | |
| ===================================================正常截图============================================================ | |
| ngrok (Ctrl+C to quit) | |
| Tunnel Status online | |
| Version 1.7/1.7 | |
| Forwarding http://test.ngrok.phpvue.com -> 127.0.0.1:80 | |
| Forwarding https://test.ngrok.phpvue.com -> 127.0.0.1:443 | |
| Web Interface 127.0.0.1:4040 | |
| # Conn 1 | |
| Avg Conn Time 0.00ms | |
| HTTP Requests | |
| ------------- | |
| GET / 200 OK | |
| GET / 200 OK | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment