
location ~ ^(\/path1|\path2)${ limit_except POST { deny all; } clIEnt_body_temp_path /path/to/app/tmp; clIEnt_body_in_file_only on; clIEnt_body_buffer_size 128K; clIEnt_max_body_size 1000M; #this option is a quick Hack to make sure files get saved on (IE this type of request goes to) on a specific server proxy_pass http://admin; proxy_pass_request_headers on; proxy_set_header X-file $request_body_file; proxy_set_body off; proxy_redirect off; # might not need? proxy_read_timeout 3m;} 这是有效的,但是处理请求的Web服务器进程(Mongrel)必须在它可以对它执行任何 *** 作之前sudo在头文件[‘X-file’]中出现的临时文件.这是因为临时文件具有600个权限.
我对这种方法不满意,这要求我们编辑/ etc / sudoers文件以允许Web服务器用户在没有密码的情况下执行sudo chmod.感觉非常不安全.
有没有办法,使用Nginx配置,更改创建的临时文件的权限,例如775?
编辑:我只是尝试在Nginx init配置中更改umask选项的值,然后重新启动Nginx,但它没有帮助.它已经在0022,我把它改为0002.在这两种情况下,它都有600个权限.
EDIT2:我也尝试在Nginx配置中的proxy_redirect行下添加这一行.
proxy_store_access user:rw group:rw all:r;
但是,它没有任何区别 – 它仍然只有用户:rw
解决方法 通过Nginx源查看,似乎唯一可以修改临时文件权限的机制是请求的request_body_file_group_access属性,请参阅ngx_http_write_request_body(): if (r->request_body_file_group_access) { tf->access = 0660;} 但即使这样也限制你到0660,它似乎不是用户可设置的属性,只有ngx_http_dav模块才能使用它.
权限最终在ngx_open_tempfile()中设置,默认为0600:
fd = open((const char *) name,O_CREAT|O_EXCL|O_RDWR,access ? access : 0600);
所以似乎目前没有基于配置的解决方案.如果您愿意/能够从源代码构建Nginx,一种可能性是应用一个简单的补丁来将权限设置为ngx_http_write_request_body()中您想要的任何内容:
+ tf->access = 0644;+ if (r->request_body_file_group_access) { tf->access = 0660; } rb->temp_file = tf; 我测试了这个并获得了以下内容,第一个文件没有修改就上传了,第二个文件带有它:
$ls -al /tmp/upload/total 984drwxr-xr-x 2 nobody root 12288 Feb 18 13:42 .drwxrwxrwt 16 root root 12288 Feb 18 14:24 ..-rw------- 1 nobody nogroup 490667 Feb 18 13:40 0000000001-rw-r--r-- 1 nobody nogroup 490667 Feb 18 13:42 0063184684总结
以上是内存溢出为你收集整理的Linux – client_body_in_file_only – 如何设置临时文件的文件权限?全部内容,希望文章能够帮你解决Linux – client_body_in_file_only – 如何设置临时文件的文件权限?所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)