我收到502错误并且在错误日志[错误] 18959#18959:* 1连接()失败(111:连接被拒绝)连接到上游.......
upstream django {
server 127.0.0.1:7000;
}
server {
listen 80;
server_name ec2-instance-address.us-west-2.compute.amazonaws.com;
access_log /srv/project/logs/access-nginx.log;
error_log /srv/project/logs/error-nginx.log;
location / {
uwsgi_pass django;
include /srv/project/conf/envs/stage/uwsgi/params;
}
location /static/ {
root /srv/project/;
index index.html index.htm;
}
location /media/ {
root /srv/project/;
index index.html index.htm;
}
location ~ ^/favicon.(\w*)$ {
alias /srv/book-stage/static/favicon.$1;
}
}
项目的uwsgi.ini文件。
[uwsgi]
socket = :7000
chmod-socket = 666
uid = nginx
gid = nginx
master = true
enable-threads = true
processes = 2
virtualenv = /srv/project
chdir = /srv/project
pythonpath = /srv/project
module = conf.wsgi
pidfile = /srv/project/uwsgi/stage.pid
daemonize = /srv/project/logs/uwsgi.log
touch-reload = /srv/project/uwsgi/touch.py
vacuum = true
log-format = %(addr) - %(user) [%(ltime)] "%(method) %(uri) %(proto)" %(status) %(size) "%(referer)" "%(uagent)"
uwsgi --ini /srv/project/conf/envs/stage/uwsgi/stage.ini
后的nginx error.log更新为新错误
[error]: *1 upstream prematurely closed connection while reading response header from upstream
答案 0 :(得分:1)
在将uwsgi --ini mysite_uwsgi.ini
添加到nginx配置的流部分并将unix:///tmp/project.sock
添加到uwsgi.ini文件后,重新启动nginx并按socket = /tmp/project.sock
启动uwsgi解决了我的问题。