Nginx出现 ERR_CONTENT_LENGTH_MISMATCH 问题

问题说明

在前端页面访问时,部分接口返回数据失败。在nginx的错误日error.log发现出现以下问题。

.......open() "/usr/local/nginx/proxy_temp/3/00/0000000003" failed (13: Permission denied) while reading upstream, client:...... server: localhost, request: "GET

原因:
nginx在做代理时,其工作进程对大文件做了缓存,这个缓存在 %nginx%/proxy_temp 目录下,主进程在读取缓存的时候由于权限问题而无法访问。

解决办法

将 proxy_temp 目录权限设置成跟 nginx 工作进程用户相同的用户。并给读权限

# 查看 nginx 配置文件中工作进程使用的用户
cat nginx.conf
...
user  nginx;
...
chown -R nginx:root /usr/local/nginx/proxy_temp

chmod -R 700 /usr/local/nginx/proxy_temp

# 重启 nginx
/usr/local/nginx/sbin/nginx -s reload
posted @ 2022-03-11 17:15  Rocky_940120  阅读(1083)  评论(0)    收藏  举报