繁体   English   中英

在nginx + uwsgi下烧瓶

[英]flask under nginx + uwsgi

我们正在开发一个烧瓶应用程序但是在尝试配置服务器4小时后我无法理解它。

这是事情:

  • vm可通过xx.xx.xx.xx访问:81

  • 在这台服务器上,我的应用程序位于:/var/hg/repositories/data/test.py

我想通过xx.xx.xx.xx:81 / ws访问此应用程序

这就是我用nginx做的:

 location = /var/hg/repositories/data { rewrite ^ /var/hg/repositories/data/; }
     location /ws { try_files $uri @ws; }
     location @ws {
        include uwsgi_params;
        uwsgi_param SCRIPT_NAME /var/hg/repositories/data;
        uwsgi_modifier1 30;
        uwsgi_pass unix:/tmp/uwsgi.sock;
     }

我有一个yaml文件来午餐uwsgi:

uwsgi:
  socket: 127.0.0.1:9090
  master: 1
  workers: 1
  chmod-socket: 666
  auto-procname: 1
  python-path: .
  pidfile: /tmp/uwsgi.pid
  daemonize: /var/log/uwsgi.log
  module: test:app

转到xx.xx.xx.xx:81给了我经典的nginx欢迎消息。

去xx.xx.xx.xx:81 / ws给了我一个404。

我究竟做错了什么?

在conf更新后,我有

  location = /var/hg/repositories/data/ location /var/hg/repositories/data/ { try_files $uri @web } location @ws { uwsgi_pass unix:/tmp/uwsgi.sock; } 

我的uwsgi conf:

uwsgi:
  socket: unix:/tmp/uwsgi.lock
  master: 1
  workers: 1
  chmod-socket: 666
  auto-procname: 1
  pidfile: /tmp/uwsgi.pid
  deamonize: /var/log/uwsgi.log
  manage-script-name: true
  mount: /ws=/var/hg/repositories/data/test.py
  callable: app

您必须在uWSGI中“安装”该应用程序,目前您已将其“挂载”为空SCRIPT_NAME

mount:/ws=test.py

可调用的:app

(删除'module'指令)就可以了。

我建议你避免使用nginx来管理SCRIPT_NAME,因为它不太聪明,使用modifier1 30实际上是一个丑陋的黑客。

只需从nginx中删除uwsgi_param和uwsgi_modifier1,并向uWSGI添加manage-script-name:true

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM