ngrok布置外网访问环境
步驟一,啟動ngrok
ngrok by @inconshreveable ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? (Ctrl+C to quit)
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ??
Session Status ? ? ? ? ? ? ? ?online ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?
Session Expires ? ? ? ? ? ? ? 6 hours, 27 minutes ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ??
Version ? ? ? ? ? ? ? ? ? ? ? 2.3.35 ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?
Region ? ? ? ? ? ? ? ? ? ? ? ?United States (us) ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?
Web Interface ? ? ? ? ? ? ? ? http://127.0.0.1:4040 ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ??
Forwarding ? ? ? ? ? ? ? ? ? ?http://8323eeb5.ngrok.io -> http://localhost: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? ? ? ? ? ? ? ? ? ? ? ? ? ??
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ??
GET /favicon.ico ? ? ? ? ? ? ? 404 NOT FOUND ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?
GET / ? ? ? ? ? ? ? ? ? ? ? ? ?200 OK ? ?
步驟二,
# nginx -c /etc/nginx/nginx.conf
# nginx -s reload
python hello.py
瀏覽器訪問:
http://8323eeb5.ngrok.io/
得到:
?
#---------------------------------------------------附錄----------------------------------------------------------------------------
hello.py
from flask import Flask app = Flask(__name__)@app.route('/') def hello_world():return 'Hello World!'if __name__ == '__main__':app.run(host="127.0.0.1",port=10071)nginx.conf
user root; worker_processes 2; error_log /etc/nginx/error.log; pid /etc/nginx/nginx.pid;events {worker_connections 1024; }http {#include /usr/local/nginx/conf/mime.types;include /etc/nginx/mime.types;default_type application/octet-stream;server {listen 80;server_name 8323eeb5.ngrok.io;access_log /var/log/nginx/access.log;location / {proxy_pass http://127.0.0.1:10071;proxy_set_header Host $host:$server_port;proxy_set_header X-Real-IP $remote_addr;proxy_set_header REMOTE-HOST $remote_addr;proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;}location /static {root /home/appleyuchi;autoindex on;}location /media {root /home/appleyuchi;autoindex on; }}}?
總結
以上是生活随笔為你收集整理的ngrok布置外网访问环境的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。