nginx favicon.ico 出现403 forbidden

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;
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值