简体   繁体   中英

uWSGI + Nginx, uWSGI can't receive request

I'm using uWSGI + Nginx to deploy a Django app. But uWSGI can't receive any request from Nginx.

WSGI app 0 (mountpoint='') ready in 1 seconds on interpreter 0x8e7250 pid: 20440 (default app)
*** uWSGI is running in multiple interpreter mode ***
spawned uWSGI master process (pid: 20440)
spawned uWSGI worker 1 (pid: 20445, cores: 1)
spawned uWSGI worker 2 (pid: 20446, cores: 1)
spawned uWSGI worker 3 (pid: 20447, cores: 1)
... no requests seen

Here's the my config files:

uwsgi.ini

[uwsgi]
chdir           = /home/laike9m/Envs/blog/My_Blog
module          = my_blog.wsgi:application
home            = /home/laike9m/Envs/blog/
master          = true
processes       = 3
socket          = /tmp/uwsgi.sock
chmod-socket    = 664
vacuum          = true

nginx.conf

server {
    listen       80;

    location /media {
        alias /home/laike9m/media;
    }

    location /static {
        alias /home/laike9m/static;
    }

    location / {
        uwsgi_pass unix:/tmp/uwsgi.sock;
        include uwsgi_params;
    }
}

If you visit http://107.170.253.157/ , it will give you 502 error. In Nginx's log:

"GET / HTTP/1.1" 502 545 "-"

What am I doing wrong? Thank you!

A few things to try:
1. make uwsgi_pass the last directive in the location block
2. just for sanity testing purposes, chmod the socket 777 instead of 664. If that resolves it, look into who owns the socket and who nginx is running as.
3. change your uwsgi config to open an HTTP socket on an alternate port and connect to it with your browser, again just for sanity checking purposes.

You also note that the nginx log seems to have no information, but that looks like the nginx access log, not the error log. Does the error log show anything different?

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