简体   繁体   English

python:从uwsgi移到http-socket

[英]python: moving from uwsgi to http-socket

I'm using a python app ( modoboa ) which used to be served with uwsgi to nginx via uwsgi-protocol. 我正在使用一个python应用程序( modoboa ),该应用程序以前曾通过uwsgi协议与uwsgi一起提供给nginx。

I'm trying out h2o server now which doesn't speak the uwsgi protocol but http. 我现在正在尝试不使用uwsgi协议但使用http的h2o服务器。

So I'm trying to migrate uwsgi from using a uwsgi-socket to a http-socket, but uwsgi throws an error "no python application found" at the point I am now. 因此,我试图将uwsgi从使用uwsgi-socket迁移到http-socket,但是在我现在的位置,uwsgi引发了错误“找不到python应用程序”。

This was in my nginx.conf : 这是在我的nginx.conf

location /modoboa/ {
        root /usr/local/www/modoboa_default/modoboa_default;
        include uwsgi_params;
        uwsgi_pass unix:/tmp/uwsgi-modoboa.sock;
        uwsgi_param UWSGI_SCRIPT modoboa_default.wsgi:application;
        uwsgi_param UWSGI_SCHEME https;
        uwsgi_param SCRIPT_NAME /modoboa;
        uwsgi_modifier1 30;
    }

This was my uwsgi.ini : 这是我的uwsgi.ini

[uwsgi]
chdir = /usr/local/www/modoboa_default
module = modoboa_default.wsgi:application
master = true
harakiri = 60
processes = 4
vhost = true
no-default-app = true

This is my uwsgi.ini now: 现在是我的uwsgi.ini

[uwsgi]
chdir = /usr/local/www/modoboa_default
module = modoboa_default.wsgi:application
master = true
harakiri = 60
processes = 4
vhost = true
no-default-app = true
http-socket=/tmp/uwsgi-http.sock
enable-threads=true
buffer-size=60000
http-keepalive=3000

I guess I'm missing something in my uwsgi.ini 我想我的uwsgi.ini中缺少某些内容


update 更新

this is what I have so far 这就是我到目前为止

h2o.conf

        "/modoboa/":
            proxy.reverse.url: "http://[unix:/tmp/uwsgi-http.sock]/"
            proxy.timeout.keepalive: 1000
            proxy.preserve-host: ON

        "/modoboa/sitestatic/":
            file.dir: /usr/local/www/modoboa_default/sitestatic/

        "/modoboa/media/":
            file.dir: /usr/local/www/modoboa_default/media/

uwsgi.ini

[uwsgi]
chdir = /usr/local/www/modoboa_default
harakiri = 60
processes = 4
http-socket = /tmp/uwsgi-http.sock
enable-threads = true
mount = /modoboa=modoboa_default.wsgi:application
manage-script-name = true

This works for the start page. 这适用于起始页。 However, when I login I will get redirected to example.com/accounts/login/ instead of example.com/modoboa/accounts/login/ 但是,当我登录时,我将被重定向到example.com/accounts/login/而不是example.com/modoboa/accounts/login/

You should remove vhost and no-default-app options if you're explicitly setting module in uWSGI configuration. 如果要在uWSGI配置中显式设置模块,则应删除vhostno-default-app选项。 With that options set, uWSGI is expecting to get information about that from HTTP server, but H2O is not setting anything. 设置了该选项后,uWSGI期望从HTTP服务器获取有关该信息的信息,但是H2O并未设置任何内容。

Also, it is insecure to user that settings with servers that can send proper headers unless you're exactly know what they're for, so remove them also from your existing configuration for nginx. 另外,对于用户来说,使用服务器发送可以发送适当标题的设置是不安全的,除非您完全知道它们的用途,因此也请从现有的nginx配置中删除它们。 You have module set in uWSGI config. 您已在uWSGI配置中设置了module

I think you must have the following in the [uwsgi] section (ie the same socket name in uwsgi.ini and nginx.conf) 我认为您必须在[uwsgi]部分中具有以下内容(即uwsgi.ini和nginx.conf中的套接字名称相同)

socket = /tmp/uwsgi-modoboa.sock

chmod-socket = 644

If 644 doesn't work, try 666 or even 777 (be aware of the security issues with wide open permission on a shared server) 如果644不起作用,请尝试666甚至777(请注意在共享服务器上具有广泛打开权限的安全问题)

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

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