nginx 服务于 html 而不是 gunicorn
nginx serving from html instead of gunicorn
我有一个 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;
}
}
从除第一个以外的所有 Location 指令中删除 =
。那就是精确匹配,而不是你想要的前缀匹配。
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;
}
我有一个 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;
}
}
从除第一个以外的所有 Location 指令中删除 =
。那就是精确匹配,而不是你想要的前缀匹配。
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;
}