我有以下配置應該工作,但如果該目錄存在於url路徑中,我仍然得到403。nginx給出403如果目錄存在
如:domainname.com/users
如果用戶目錄存在,我得到403,而不是它加載的index.html。
server {
listen 80;
access_log /var/log/nginx/access.log;
error_log /var/log/nginx/error.log;
server_name www.domainname.com;
return 301 https://www.domainname.com$request_uri;
root /usr/share/nginx/dist/;
index index.html;
location/{
autoindex off;
try_files $uri /index.html =404;
}
# these settings are from https://github.com/h5bp/server-configs-nginx/blob/master/h5bp/location/expires.conf
# feel free to change as much as you like
# cache.appcache, your document html and data
location ~* \.(?:manifest|appcache|html?|xml|json)$ {
expires -1;
access_log logs/static.log;
}
# Feed
location ~* \.(?:rss|atom)$ {
expires 1h;
add_header Cache-Control "public";
}
# Media: images, icons, video, audio, HTC
location ~* \.(?:jpg|jpeg|gif|png|ico|cur|gz|svg|svgz|mp4|ogg|ogv|webm|htc)$ {
expires 1M;
access_log off;
add_header Cache-Control "public";
}
# CSS and Javascript
location ~* \.(?:css|js)$ {
expires 1y;
access_log off;
add_header Cache-Control "public";
}
}
運行nginx的用戶可以使用當前權限訪問domainname.com的根目錄嗎?對於根目錄內的/ users /文件夾以及其中的任何文件也是同樣的問題。 –
是的,運行nginx的用戶可以使用當前權限訪問domainname.com的根目錄和/ users目錄,並且一切正常,唯一的問題是目錄名稱與輸入的路由衝突。 – rohit
..你不處理符號鏈接嗎? –