【发布时间】:2014-05-27 00:01:10
【问题描述】:
我正在尝试在我的网络服务器上使用 django send_mail 函数 gmail SMTP 发送电子邮件,但我收到了 502 Bad Gateway 错误。
我正在使用 nginx 和 gunicorn。
这是我的错误日志:
2014/04/12 16:46:55 [error] 26846#0: *11 upstream prematurely closed connection while
reading response header from upstream, client: 179.162.163.62, server: example.com,
request: "POST /contact/ HTTP/1.1", upstream: "http://127.0.0.1:9000/contact/", host:
"example.com", referrer: "http://example.com/contact/"
Ngnix 文件:
upstream example_gunicorn {
server 127.0.0.1:9000 fail_timeout=0;
}
server {
listen 80;
client_max_body_size 4G;
server_name .example.com;
keepalive_timeout 5;
location /static/ {
alias /deploy/sites/example/static/; # STATIC_ROOT
expires 30d;
}
location /media/ {
alias /deploy/sites/example/media/; # MEDIA_ROOT
expires 30d;
}
location / {
# checks for static file, if not found proxy to app
try_files $uri @proxy_to_app;
}
location @proxy_to_app {
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_redirect off;
proxy_pass http://example_gunicorn;
}
}
【问题讨论】:
-
检查 django 错误日志
标签: python django nginx gunicorn supervisord