我在使用 NGINX 时遇到随机 403 错误的问题。在页面“profile/user.name.1”上,我有静态图像,但它们无法加载。我收到以下消息:
"Failed to load resource: the server responded with a status of 403 (Forbidden)".
当我尝试从此页面明确访问另一个页面时,我收到“403 Forbidden”消息。我使用用户“nginx”运行 nginx,我尝试使用“myuser nginx”运行它,从http://nicholasorr.com/blog/2008/07/22/nginx-engine-x-what-a-pain-in-the-bum/
该图像文件夹的权限为:
drwxr-xr-x 2 myuser nginx 4096 5 jun 20:54 pics
我的 index.php 文件的权限是:
-rwxr-xr-x 1 myuser nginx 2517 11 jun 23:34 index.php
编辑:当我检查整个路径的权限时,使用:
namei -mo /usr/share/nginx/html/myuser/public/img/pics
我有:
drwxr-xr-x root root /
drwxr-xr-x root root usr
drwxr-xr-x root root share
drwxr-xr-x root root nginx
drwxr-xr-x root root html
drwxr-xr-x myuser nginx myuser
drwxr-xr-x myuser nginx public
drwxr-xr-x myuser nginx img
drwxr-xr-x myuser nginx pics
我该如何修复随机 403 错误?
答案1
解决了,奇怪的是我的 NGINX default.conf 配置错误。我使用了在网上找到的配置,我只是评论了这两个:
location ~ /\. {
deny all; access_log off;
log_not_found off;
}
if ($http_referer ~* (jewelry|viagra|...|babes)) {
return 403;
}