【发布时间】:2019-07-05 00:34:04
【问题描述】:
我有一个 nginx / gunicorn / django 应用程序我已经设置了以下
https://medium.com/@_christopher/deploying-my-django-app-to-a-real-server-part-ii-f0c277c338f4
当我从浏览器转到主 IP 时它可以工作(我让 Django 尝试了这些 URL 模式,按以下顺序:admin/...)但是当我转到 /admin 时,我得到了 404。Nginx 日志如下如下:
2019/07/05 00:30:28 [error] 13600#13600: *1 open() "/usr/share/nginx/html/admin" failed (2: No such file or directory), client: 186.190.207.228, server: 127.0.0.1, request: "GET /admin HTTP/1.1", host: "128.199.62.118"
所以它试图从 html/ 提供文件而不是提供 gunicorn,为什么?
Nginx 配置:
server {
listen 80;
server_name 127.0.0.1;
location = /favicon.ico {access_log off;log_not_found off;}
location = /static/ {
root /home/juan/site;
}
location = /media/ {
root /home/juan/site;
}
location = / {
include proxy_params;
proxy_pass http://unix:/home/juan/site/site.sock;
}
}
【问题讨论】:
-
尝试设置
listen 8000并重启nginx,然后在浏览器中访问127.0.0.1:8000。如果它有效,则意味着您有另一台服务器正在侦听端口 80。