【问题标题】:nginx location proxy shows not foundnginx 位置代理显示未找到
【发布时间】:2018-09-27 15:47:13
【问题描述】:

我有一个 VPS 和 NGINX,我正在尝试运行一个烧瓶应用程序,我希望烧瓶应用程序的地址类似于 site.com/flask 但位置不适用于此,它只运行主地址 site.com

server {
    listen 80;
    listen 443 ssl;
        ssl_certificate /etc/letsencrypt/live/bot.itarashe.zone/cert.pem ;
        ssl_certificate_key /etc/letsencrypt/live/bot.itarashe.zone/privkey.pem ;
        ssl_trusted_certificate /etc/letsencrypt/live/bot.itarashe.zone/chain.pem ;
    server_name bot.itarashe.zone www.bot.itarashe.zone ;

    location = ~^/flask/ {
        include proxy_params;
        proxy_pass http://unix:/home/saeb/py/flask/myproject/myproject.sock;
    }
    location / {}
}

但如果我删除~^/flask

它在主地址工作

        ssl_certificate /etc/letsencrypt/live/bot.itarashe.zone/cert.pem ;
        ssl_certificate_key /etc/letsencrypt/live/bot.itarashe.zone/privkey.pem ;
        ssl_trusted_certificate /etc/letsencrypt/live/bot.itarashe.zone/chain.pem ;
    server_name bot.itarashe.zone www.bot.itarashe.zone ;

    location / {
        include proxy_params;
        proxy_pass http://unix:/home/saeb/py/flask/myproject/myproject.sock;
    }

}

我试过了

location /flask {}
location /flask/ {}
location ~^/flask {}
location = ...

他们都没有工作, 访问日志是:

104.244.78.207 - - [27/Sep/2018:01:50:13 -0400] "GET /flask/ HTTP/1.1" 404 209 "-" "Mozilla/5.0 (X11; Linux x86_64; rv:62.0) Gecko/20100101 Firefox/62.0"

并且错误日志显示没有错误:

sudo tail -f /var/log/nginx/error.log
[sudo] password for saeb: 
2018/09/27 00:15:50 [error] 2650#2650: *13 open() "/usr/share/nginx/html/robots.txt" failed (2: No such file or directory), client: 54.175.74.27, server: bot.itarashe.zone, request: "GET /robots.txt HTTP/1.1", host: "bot.itarashe.zone"
2018/09/27 00:27:23 [error] 2650#2650: *16 open() "/usr/share/nginx/html/robots.txt" failed (2: No such file or directory), client: 66.249.66.76, server: bot.itarashe.zone, request: "GET /robots.txt HTTP/1.1", host: "oldflight.ir"
2018/09/27 00:27:23 [error] 2650#2650: *17 open() "/usr/share/nginx/html/assets/font/IranSans/IRANSans-Medium-web.woff2" failed (2: No such file or directory), client: 66.249.66.75, server: bot.itarashe.zone, request: "GET /assets/font/IranSans/IRANSans-Medium-web.woff2 HTTP/1.1", host: "oldflight.ir"
2018/09/27 01:09:02 [notice] 2811#2811: signal process started
2018/09/27 01:27:45 [notice] 2831#2831: signal process started
2018/09/27 01:42:01 [notice] 2876#2876: signal process started
2018/09/27 01:42:41 [notice] 2889#2889: signal process started
2018/09/27 01:43:54 [notice] 2902#2902: signal process started
2018/09/27 01:44:38 [notice] 2915#2915: signal process started
2018/09/27 01:50:06 [notice] 2936#2936: signal process started

【问题讨论】:

    标签: nginx flask gunicorn


    【解决方案1】:

    好的,我的问题解决了,Nginx 完成了它需要做的事情,它调用了套接字,但使用了/flask 我没有定义@app.route('/flask')

    【讨论】:

      猜你喜欢
      • 2017-04-27
      • 2019-07-31
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-06-29
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多