Gunicorn Websocket Worker not using SCRIPT_NAME env

Viewed 31

I'm trying to run the gunicorn-websockets worker on the command line with gunicorn -k geventwebsocket.gunicorn.workers.GeventWebSocketWorker -w 1 --threads 20 wsgi:app -b 0.0.0.0:5000 --env SCRIPT_NAME=/asdf

However under ip:5000/asdf, I get a 404 error and unable to reach my webpage. However under ip:5000, I'm able to reach it.

If I use the regular gevent worker, as I'm able to reach the ip:5000/asdf using SCRIPT_NAME. However, I need to work with websockets, and use the SCRIPT_NAME, but it seems gevent-websockets worker is unable to use SCRIPT_NAME.

Relevant Apache.conf section (asdf/ws is where the websocket is)

RewriteEngine on
RewriteCond %{REQUEST_URI}  ^/asdf/ws [NC]
RewriteCond %{QUERY_STRING} transport=websocket    [NC]
RewriteRule /(.*)           ws://127.0.0.1:5000/$1 [P,L]

<Location /asdf>
        SSLRequireSSL
        ProxyPass http://127.0.0.1:5000/asdf
        ProxyPassReverse http://127.0.0.1:5000/asdf
        RequestHeader set X-FORWARDED-PROTOCOL ssl
        RequestHeader set X-FORWARDED-SSL on
</Location>

I'm able to connect under /asdf through gevent, but on my websocket protocol I get RuntimeError: You need to use the gevent-websocket server. See the Deployment section of the documentation for more information. error, which is expected - and I fall back on transport.

However I want to connect under '/asdf' with the websocket worker, and it doesn't work. I also need to use SCRIPT_NAME. Thanks

1 Answers

Ok, I gave up and just used eventlet. Though I would love to know why gevent-websocket doesn't work.

Related