简体   繁体   中英

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.

I'm trying out h2o server now which doesn't speak the uwsgi protocol but http.

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.

This was in my 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]
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]
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


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/

You should remove vhost and no-default-app options if you're explicitly setting module in uWSGI configuration. With that options set, uWSGI is expecting to get information about that from HTTP server, but H2O is not setting anything.

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. You have module set in uWSGI config.

I think you must have the following in the [uwsgi] section (ie the same socket name in uwsgi.ini and 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)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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