【发布时间】:2020-04-09 11:19:06
【问题描述】:
我已经部署了我的 django 应用程序,但出现 500 错误。当我输入主页网址“mysite.com”时,它会出现错误并且不会加载,但是当我输入“mysite.com/careers”或“mysite.com/sell”时,它恰好是完全静态页面,它很漂亮。主页和其他具有动态数据的页面不提供。 在阅读了一些相关问题之后,这似乎是一个 Gunicorn 问题。 这里可能是什么问题?以下是 Nginx 的错误日志。
Nginx 错误日志:
2019/12/16 17:30:15 [error] 20605#20605: *1370 connect() to unix:/run/gunicorn.sock failed (111: Connection refused) while connecting to upstream, client: xxx.xxx.xx.xx, server: xxx.xxx.xxx.xxx, request: "GET / HTTP/1.1", upstream: "http://unix:/run/gunicorn.sock:/", host: "mysite.com"
nginx .conf 文件:
user www-data;
worker_processes auto;
pid /run/nginx.pid;
include /etc/nginx/modules-enabled/*.conf;
events {
worker_connections 768;
# multi_accept on;
}
http {
##
# Basic Settings
##
client_max_body_size 0;
proxy_max_temp_file_size 0;
proxy_buffering off;
sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 65;
types_hash_max_size 2048;
# server_tokens off;
...
}
nginx 站点可用文件:
server {
listen 80;
server_name xxx.xxx.xxx.xxx mysite.com www.mysite.com;
location = /favicon.ico { access_log off; log_not_found off; }
location /static/ {
root /home/djangoadmin/pyapps/MySite;
}
location /media/ {
root /home/djangoadmin/pyapps/MySite;
}
location / {
include proxy_params;
proxy_pass http://unix:/run/gunicorn.sock;
}
}
如果您能帮我们解决这个问题,我们将不胜感激。我快到了!
【问题讨论】:
标签: django nginx gunicorn nginx-reverse-proxy nginx-config