我得到了
当我击中http://ec2-X-YZ-ABC-EFG.compute-1.amazonaws.com/admin
.
我很确定我的 Django 应用程序没有任何问题,因为该应用程序是空的,即。我刚刚使用创建了该应用程序django-admin startproject tempo
仅仅这个改变——ALLOWED_HOSTS = ['*']
,以便它接受来自任何 IP 的请求。
由于这是一个开发服务器并且不包含任何数据,因此我允许来自任何主机的请求。这是我的入境规则,
Ports Protocol Source
80 tcp 0.0.0.0/0, ::/0
22 tcp 0.0.0.0/0, ::/0
443 tcp 0.0.0.0/0, ::/0
这是我的/etc/nginx/sites-enabled/tempo
upstream tempo-server {
server unix:///home/ubuntu/tempo/tempo.sock;
}
server {
error_log /var/log/nginx/tempo/error.log;
access_log /var/log/nginx/tempo/access.log;
listen 80;
server_name X.YX.ABC.DEF;
location = /media/ {
root /home/ubuntu/tempo/media;
}
location / {
include /etc/uwsgi/sites/uwsgi_params;
uwsgi_pass tempo-server;
}
}
这是我的uwsgi.ini
file
[uwsgi]
chdir = /home/ubuntu/tempo
module = tempo.wsgi
home = /home/ubuntu/seatr/venv-seatr
master = true
processes = 10
socket = /home/ubuntu/tempo/tempo.sock
chmod-socket = 777
vacuum = true
另外,uwsgi 启动没有错误,.sock 文件也创建成功。
nginxerror.log
shows:
2019/04/04 20:03:48 [error] 30261#30261: *9 upstream prematurely closed connection while reading response header from upstream, client: 129.219.8.129, server: X.YZ.ABC.DEF, request: "GET /admin HTTP/1.1", upstream: "uwsgi://unix:///home/ubuntu/tempo/tempo.sock:", host: "ec2-X-YZ-ABC-DEF.compute-1.amazonaws.com"
PS:我的启用站点(软链接)仅包含此tempo
文件,可用站点包含几个文件。
我已经在多个地方读过这个问题,但没有答案:
here https://djbook.ru/forum/topic/3286/
here http://librelist.com/browser/flask/2013/4/15/keyerror-request-method-when-running-getting-started-application-on-uwsgi/