Nginx如何才能写入文件到proxy_temp中?

线上Nginx error.log中发现了这么一个异常

2019/01/26 05:18:00 [crit] 23913#23913: *232549515 open() "/usr/local/nginx/proxy_temp/0/27/0000004270" failed (13: Permission denied) while reading upstream, client: 100.97.126.50, server: foo.bar.com ...

搜了一下 有人是这么说的

问题就出在proxy_temp_file_write_size上,当你的文件超过该参数设置的大小时,nginx会先将文件写入临时目录

于是想在本地模拟

  1. 取消proxy_temp的读写权限

    d--------- 2 zhugw admin 64 Jan 9 15:26 proxy_temp

  2. 设置proxy_temp_file_write_size只有256字节
    location / {

    proxy_buffer_size 256;
    proxy_buffers 2 256;
    proxy_busy_buffers_size 256;
    proxy_temp_file_write_size 256;

    }

  3. 然后请求一个332KB的图像 我想应该会复现线上的错误日志吧

    ➜ ~ curl -I http://localhost/Boston_City_...
    HTTP/1.1 200 OK
    Server: nginx/1.15.8
    Date: Sat, 26 Jan 2019 13:12:52 GMT
    Content-Type: image/jpeg
    Content-Length: 339773
    Last-Modified: Sat, 26 Jan 2019 11:41:10 GMT
    Connection: keep-alive
    ETag: "5c4c4756-52f3d"
    Accept-Ranges: bytes

但是Nginx error.log中并没有错误日志 甚至尝试了并发请求都没有错误日志产生

➜  ~ ab -n 1000 -c 50 http://localhost/Boston_City_Flow.jpg

什么情况这是? 怎么样才能复现这个错误呢?

"/usr/local/nginx/proxy_temp/0/27/0000004270" failed (13: Permission denied) while reading upstream

阅读 7.6k
撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题