Reputation: 4557
I'm serving my app with uWSGI using uwsgi --http-socket 127.0.0.1:3031 -w app:app
, which works when I go to 127.0.0.1:3031
in a browser. I want to use Nginx, so I told it to uwsgi_pass
to that url, but now I get a 502 Bad Gateway error. How do I put uWSGI behind Nginx?
server {
listen 8080;
server_name 127.0.0.1;
location / {
uwsgi_pass 127.0.0.1:3031;
include uwsgi_params;
}
location /static {
alias /static/folder/location;
}
}
2016/05/16 19:50:09 [error] 6810#0: *4 upstream prematurely closed
connection while reading response header from upstream, client:
127.0.0.1, server: 127.0.0.1, request: "GET / HTTP/1.1", upstream:
"uwsgi://127.0.0.1:3031", host: "127.0.0.1:8080"
Upvotes: 1
Views: 1636
Reputation: 21
You can use http-socket between nginx and uWSGI. For example, if you launch your python app with uWSGI:
uwsgi --http-socket 127.0.0.1:3031 --wsgi-file application.py --callable app --processes 4 --threads 2 --stats 127.0.0.1:9191
Configure Nginx with:
location / {
proxy_pass http://127.0.0.1:3031/;
}
Upvotes: 1
Reputation: 127180
Use socket
, not http-socket
.
uwsgi --socket 127.0.0.1:3031 -w app:app
http-socket
makes uWSGI act like a web server that speaks HTTP, and is not correct if you're using Nginx, since it understands uWSGI directly.
Upvotes: 0