我在另一个问题中证实,我确实可以仅使用Nginx
和Daphne
运行Django应用,并根据他们的建议修改了nginx
配置代码。
应用程序在127.0.0.1:8001上与Daphne一起运行
但是,我遇到了403禁止错误。 Nginx错误日志显示:
"2019/03/07 11:23:48 [error] 16642#16642: *11 directory index of "/path/to/app" is forbidden, client: xx.xxx.xx.xx, server: app.com, request: "GET / HTTP/1.1", host: "www.app.com", referrer: "http://www.app.com""
我仍然面临着403,并且感谢任何可能找到问题出处的人。
我的nginx配置
upstream socket {
ip_hash;
server 127.0.0.1:8001 fail_timeout=0;
}
server {
listen 80;
#listen [::]:80 ipv6only=on;
server_name your.server.com;
access_log /etc/nginx/access.log;
root /var/www/html/someroot;
location / {
#autoindex on;
# First attempt to serve request as file, then
# as directory, then fall back to displaying a 404.
# try_files $uri =404;
#proxy_set_header X-Real-IP $remote_addr;
#proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
#proxy_set_header Host $http_host;
#proxy_set_header X-NginX-Proxy true;
#proxy_pass http://socket;
#proxy_redirect off;
#proxy_http_version 1.1;
#proxy_set_header Upgrade $http_upgrade;
#proxy_set_header Connection "upgrade";
#proxy_redirect off;
#proxy_set_header X-Forwarded-Proto $scheme;
#proxy_cache one;
#proxy_cache_key sfs$request_uri$scheme;
}
listen 443 ssl; # managed by Certbot
ssl_certificate /etc/letsencrypt/live/some/fullchain.pem;
# managed by Certbot
ssl_certificate_key /etc/letsencrypt/live/some/privkey.pem;
# managed by Certbot
include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
if ($scheme != "https") {
return 301 https://$host$request_uri;
}
}
答案 0 :(得分:0)
我不得不将try_files $uri=404;
更改为try_files $uri $uri/ =404;
,这解决了主页的问题,但是其他页面仍然显示404错误。