在nginx + uwsgi下烧瓶 [英] flask under nginx + uwsgi

查看:189
本文介绍了在nginx + uwsgi下烧瓶的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



下面是这个事情:

我们正在开发一个烧瓶应用程序,但经过4个小时的努力配置服务器,我无法弄清楚。
$ b


  • 可通过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
$ b

前往xx.xx.xx.xx:81给了我经典的nginx欢迎信息。



xx.xx.xx.xx:81 / ws给了我404。



我做错了什么?

<在conf更新之后,我有

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


我的uwsgi conf:



$ p $ u code $ u $ s
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

删除'模块'指令)将做的伎俩。

我建议你避免nginx管理SCRIPT_NAME,因为它不是太聪明,使用modifier1 30真的

只要从nginx中删除uwsgi_param和uwsgi_modifier1,然后添加manage-script-name:true到uWSGI


we're developing a flask application but after 4 hours trying to configure the server I can't figure it out.

Here's the thing:

  • the vm is accessible through xx.xx.xx.xx:81

  • on this server, my app is at : /var/hg/repositories/data/test.py

I'd like to access this application through xx.xx.xx.xx:81/ws

This is what I did with 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;
     }

I have a yaml file to lunch 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

Going to xx.xx.xx.xx:81 gives me the classic nginx welcome message.

Going to xx.xx.xx.xx:81/ws gives me a 404.

What am I doing wrong?

after conf update, i have

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

my 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

解决方案

You have to "mount" the app in uWSGI, currently you have "mounted" it as empty SCRIPT_NAME

mount: /ws=test.py

callable: app

(remove the 'module' directive) will do the trick.

I suggest you to avoid nginx managing SCRIPT_NAME as it is not too smart about that, and using modifier1 30 is really an ugly hack.

Just remove both uwsgi_param and uwsgi_modifier1 from nginx and add manage-script-name: true to uWSGI

这篇关于在nginx + uwsgi下烧瓶的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆