[英]Unable to find cause of 403 Forbidden error: Nginx Daphne Django
I have had confirmation in another question that I can indeed run a Django app using only Nginx
and Daphne
and have modified my nginx
config code as per their suggestion. 我在另一个问题中得到证实,我确实可以仅使用
Nginx
和Daphne
来运行Django应用,并根据他们的建议修改了我的nginx
配置代码。
The application is running with Daphne on 127.0.0.1:8001 该应用程序在127.0.0.1:8001上与Daphne一起运行
However, I am running into a 403 Forbidden error. 但是,我遇到了403禁止错误。 The nginx error logs say:
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""
I'm still facing a 403 and would be grateful to anyone who may be able to locate where the problem is coming from. 我仍然面临着403,并感谢任何可能找到问题出处的人。
My nginx config 我的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;
}
}
I had to change try_files $uri=404;
我不得不更改
try_files $uri=404;
to try_files $uri $uri/ =404;
到
try_files $uri $uri/ =404;
and that fixed the issue of the main page however other pages still display 404 error. 并解决了主页的问题,但是其他页面仍然显示404错误。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.