【发布时间】:2017-07-30 23:12:28
【问题描述】:
我收到 502 错误,并且在错误日志 [error] 18959#18959: *1 connect() failed (111: Connection refused) while connection to upstream.......
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文件。
mysite_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
【问题讨论】:
-
您的 uwsgi.ini 文件也需要研究,您也可以发布一下吗?
-
@abcdn 更新有问题。
-
看起来应该可以工作。当你运行
uwsgi --ini mysite_uwsgi.ini时你看到了什么? -
@abcdn [uWSGI] 从 /srv/project/conf/envs/stage/uwsgi/stage.ini 获取 INI 配置
-
在 nginx 错误日志中错误更改为 '[error] 21705#21705: *1 上游过早关闭连接,同时从上游读取响应头'
标签: django amazon-web-services nginx uwsgi