【发布时间】:2016-04-03 17:35:12
【问题描述】:
我关注了this tutorial,以便将我的 Django 应用程序部署在带有 uWSGI 和 Nginx 的 DigitalOcean VPS 上。静态文件运行良好,但 Django 应用程序本身却不行。 (404 未找到 - nginx/1.9.6)
# Where to look for content (static and media)
root /srv/www/$host/;
# Allow gzip compression
gzip_types text/css application/json application/x-javascript;
gzip_comp_level 6;
gzip_proxied any;
# Look for files with .gz to serve pre-compressed data
gzip_static on;
server {
listen 80;
# nginx docs recommend try_files over "if"
location / {
# Try to serve existing files first
try_files $uri @proxy =404;
}
location @proxy {
# Pass other requests to uWSGI
uwsgi_pass unix://srv/apps/_/server.sock;
include uwsgi_params;
}
}
【问题讨论】:
-
确保套接字
/srv/apps/_/server.sock存在。如果没有,请检查您的 uWSGI 配置。 -
try_files的语法错误。@proxy或=404应该是最后一个元素 - 你不能同时拥有这两个元素。见this document -
/srv/apps/_/server.sock存在。 -
如何使用
try_files?
标签: python django nginx http-status-code-404 uwsgi