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:80                                                                       
Forwarding                    https://8323eeb5.ngrok.io -> http://localhost:80                                                                      
                                                                                                                                                    
Connections                   ttl     opn     rt1     rt5     p50     p90                                                                           
                              1       0       0.00    0.00    14.62   14.62                                                                         
                                                                                                                                                    
HTTP Requests                                                                                                                                       
-------------                                                                                                                                       
                                                                                                                                                    
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; }
  }
  
}

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值