您的位置:首页 > 运维架构 > Nginx

nginx favicon.ico 出现403 forbidden

2015-10-23 15:48 1276 查看

nginx.conf配置

为了允许favicon.ico可以转发,配置如下:

location ~ (favicon.ico) {
root html;
}


root html把项目的目录指向到/usr/local/nginx/html

问题出现原因

因为nginx的worker线程是以nobody用户运行的,而/usr/local/nginx/html下面文件的访问权限为:

MacBook-Pro:~ yangyamin$ ls -la /usr/local/nginx/html/
total 144
drwxr-xr-x@  5 root  wheel    170 10 22 21:28 .
drwxr-xr-x  27 root  wheel    918 10 23 14:00 ..
-rw-r--r--@  1 root  wheel    537 10 22 15:48 50x.html
-rw-r-----   1 root  wheel  62134 10 22 21:28 favicon.ico
-rw-r--r--@  1 root  wheel    612 10 22 15:48 index.html


发现favicon.ico文件没有授予other 读权限

解决方法

sudo chmod a+r /usr/local/nginx/html/favicon.ico

把/usr/lo

其他思路

[未验证] 可以把nginx.conf中的user项设置为:

user  root;
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: