Working with uWSGI using unix sockets?
See original GitHub issueThanks for this great library!
I’m trying to use it with uWSGI via unix sockets without success, and am wondering if anyone has any ideas. The set up is Python 3.5 + Nginx + uWSGI.
(Sorry if this is not the right place to ask - I hope it may be helpful to others in similar situations.)
The Nginx part is working I think:
server {
listen 80;
location / {
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "Upgrade";
proxy_http_version 1.1;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_pass http://127.0.0.1:5000;
}
}
And that’s because if I run the uWSGI server using HTTP, it works fine:
uwsgi --http :5000 --gevent 1000 --http-websockets --master --module myapp.wsgi --callable app
But if I run it using unix socket, it doesn’t. I have this Nginx setup:
server {
listen 5000;
gzip on;
gzip_disable "msie6";
gzip_min_length 1000;
gzip_vary on;
gzip_comp_level 6;
gzip_types text/css application/json application/x-javascript text/javascript;
location / {
include uwsgi_params;
uwsgi_pass unix:///tmp/myapp.sock;
}
}
and the following uWSGI setup:
[uwsgi]
chdir = /home/ubuntu/myapp
module = myapp.wsgi
callable = app
home = /home/ubuntu/myapp/env
master = true
processes = 10
gevent = 1000
http-websockets = true
socket = /tmp/myapp.sock
chmod-socket = 660
vacuum = true
die-on-term = true
The error is WebSocket is closed before the connection is established.
Issue Analytics
- State:
- Created 7 years ago
- Comments:13 (2 by maintainers)
Top Results From Across the Web
Setting up Django and your web server with uWSGI and nginx
In this tutorial we will set up uWSGI so that it creates a Unix socket, and serves responses to the web server via...
Read more >Writing to a uWSGI unix socket - python - Stack Overflow
I have a Python wsgi app that is served by uWSGI behind NGinx. NGinx listens on the network and forwards requests to the...
Read more >uWSGI TCP/IP host:port vs Unix socket - Server Fault
Changing back to localhost:port and no errors in the logs. The pages are loading with both configurations. We would prefer Unix sockets because...
Read more >Problem with unix socket nginx-uwsgi - Raspberry Pi Forums
The web server is nginx and has a working php-fpm setup using a unix socket in the /run/php folder. I then added a...
Read more >Django and Nginx through uwsgi is not working - Google Groups
Here my configurations files. ... When i launch "systemctl start nginx" nginx is started with error: connect() to unix:///socket/uwsgi.sock failed (111: ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Oh I got it working. Turns out you can’t specify the
process
param. Thanks again for the help!Here’s the working config:
Nginx:
uWSGI:
Nothing fancy there: