V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
V2EX 提问指南
mzmxcvbn
V2EX  ›  问与答

Nginx+gunicorn+Supervisor 部署 flask 一直不成功?

  •  
  •   mzmxcvbn · 2017-04-20 08:53:24 +08:00 · 1393 次点击
    这是一个创建于 2567 天前的主题,其中的信息可能已经有所发展或是发生改变。

    用的是阿里云,按着教程走到最后,可用浏览器外部访问一直显示的是 Nginx 运行成功的欢迎界面。我在服务器上 curl 127.0.0.1:80 显示的是 nginx 欢迎界面, curl 127.0.0.1:8000 显示的是我网站的首页。我想 gunicorn 和 Supervisor 应该是成功了,问题应该在 nginx 这吧, nginx 配置如下,不知为何转发一直不成功。

    nginx 配置文件

    server {  
            listen   80;  
            server_name localhost;
            root /home/mo/blog;
            access_log /home/mo/blog/logs/access.log;
            error_log /home/mo/blog/logs/access.log;
            location / {  
                proxy_set_header X-Forward-For $proxy_add_x_forwarded_for;  
                proxy_set_header Host $http_host;  
                proxy_redirect off;  
                if (!-f $request_filename) {  
                    proxy_pass http://127.0.0.1:8000;  
                    break;  
                }  
            }  
        }
    

    gunciorn 配置

    workers = 3
    bind = 127.0.0.1:8000
    
    1 条回复    2017-06-05 10:59:00 +08:00
    toarya
        1
    toarya  
       2017-06-05 10:59:00 +08:00
    sudo rm /etc/nginx/sites-enabled/default
    把默认配置的欢迎页面去掉。
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   955 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 25ms · UTC 19:03 · PVG 03:03 · LAX 12:03 · JFK 15:03
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.