[alibaba/tengine]proxy_cache 静态文件缓存目录权限不足

2024-08-21 375 views
4

版本2.3.2下使用proxy_cache反向代理缓存静态文件出现权限不足错误

1.访问环境出现500 2.日志error.log内出现opendir (proxy_temp_path/proxy_cache_path)permission denied错误

1.worker进程是nobody或者其他时,应该要有权限使用cache目录

1.正常配置proxy_temp_path/proxy_cache_path,nginx -t测试配置文件无问题 2.使用root用户启动nginx,查看到worker进程属主为nobody 3.进程启动后会自动创建上述配置的缓存路径,看目录结构无问题,目录属主为nobody,组为root 4.但此时报错,出现permission denied。 5.修改nginx.conf中user nobody为user root无上述错误

1.同样的配置nginx worker进程为nobody时,无问题

Ⅵ. Environment:
  • Tengine version (2.3.2):
  • OS (centos6.5):
  • Kernel (2.6.32-431.el6.x86_64):
  • Others:

回答

4

nginx的rpm包看了一些,文件夹授权是这样写的,参考下:

dir %attr(0755, root, root) "/var/cache/nginx"
# Add the "nginx" user
getent group nginx >/dev/null || groupadd -r nginx
getent passwd nginx >/dev/null || \
    useradd -r -g nginx -s /sbin/nologin \
    -d /var/cache/nginx -c "nginx user"  nginx
exit 0
9

nginx是编译安装的,在提这个issue之前就在nginx把这个问题测试了,最奇怪的是tengine、nginx编译参数一致,且主要配置都是一样的,它们启动时自动创建的文件夹权限也是一样的,但是实际浏览器访问tengine的时候看日志发现对它自己自动创建的文件夹提示权限有错误,修改为777也不行。