deny/allow)autoindex off) 且無索引檔allow 10.0.0.0/8; deny all;)Nginx 執行用戶 (如 www-data, nginx) 需要:
範例:訪問 /usr/local/nginx/html/image.jpg 需:
chmod 755 / /usr /usr/local /usr/local/nginx /usr/local/nginx/html
chmod 644 /usr/local/nginx/html/image.jpg
配置:
location / {
root /var/www/html;
index index.html index.htm; # 缺少 index.php
}
若目錄下只有 index.php,Nginx 找不到匹配的 index 檔,直接回 403。
修正: index index.html index.htm index.php;
同理需補充:index.jsp, index.py 等。
nginx -t 確認語法無誤。ls -l 檢查目標檔案與所有父目錄權限。ps aux | grep nginx 確認 worker 進程用戶。error.log 關鍵字 Permission denied 或 directory index of ... is forbidden。