关键词 DEBUG ,NGINX ,Permission denied
[问题] 页面访问所需资源访问失败。访问日志记录显示成功,错误日志报错: Permission denied
如下:
access.log
【xxx.xxx.xxx.xxx】 - - [15/Mar/2023:13:14:36 +0800] "GET /static/css/2.068df95f.chunk.css HTTP/1.1" 200 113939 "https://[host_name]/home/video?token=new1" "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:109.0) Gecko/20100101 Firefox/110.0"
【xxx.xxx.xxx.xxx】 - - [15/Mar/2023:13:14:36 +0800] "GET /static/js/main.549e6a20.chunk.js HTTP/1.1" 200 163425 "https://[host_name]/home/video?token=new1" "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:109.0) Gecko/20100101 Firefox/110.0"
【xxx.xxx.xxx.xxx】 - - [15/Mar/2023:13:14:36 +0800] "GET /static/css/main.dd3810f3.chunk.css HTTP/1.1" 200 97903 "https://[host_name]/home/video?
---------error.log--------------
2023/03/15 13:14:36 [crit] 17906#17906: *1 open() "/var/cache/nginx/proxy_temp/1/00/0000000001" failed (13: Permission denied) while reading upstream, client: 【xxx.xxx.xxx.xxx】, server: 10.78.170.53, request: "GET /static/js/main.549e6a20.chunk.js HTTP/1.1", upstream: "http://127.0.0.1:3001/static/js/main.549e6a20.chunk.js", host: "[host_name]", referrer: "https://[host_name]/home/video?token=new1"
2023/03/15 13:14:36 [crit] 17906#17906: *4 open() "/var/cache/nginx/proxy_temp/2/00/0000000002" failed (13: Permission denied) while reading upstream, client:
【解决方法】
查看nginx进程ps aux|grep nginx
发现都是nobody的进程,但是nginx的目录都是root用户, 而且root启动。
查看nginx.conf:
user nobody
改成:user root
注意:只是注释掉(#user nobody),没重新赋值默认还是nobody
停止nginx -s stop
重启nginx -c nginx.conf