[PATCH] optionally avoid sending body of PUT request before X-Accel redirect

Jakub Moscicki Jakub.Moscicki at cern.ch
Wed Aug 10 08:58:31 UTC 2016


Hello,

Thank you for your suggestion. Experimenting I have stumbled on the config question:

What is the easiest way of *conditionally* adding "proxy_pass_request_body off” to a location? If method is PUT then I want to set: "proxy_pass_request_body off”.

I have quite a complex location block which I would like to avoid to copy/paste in my configuration. 

I would like to do something like this:

location ~/my-uri(*.) {

if ($request_method = PUT) {
proxy_pass_request_body off;
}
   … complex and long location handler ...
}


The only way I imagined so far is with conditional rewrite in front of my original location - but that complicates my config file a lot with huge copy/paste blocks. Something like that:

location ~ ^my-uri(*.) {
  if ($request_method = PUT) {
   rewrite ^ /internal_location_put$1;
 }
rewrite ^ /internal_location_other$1;
}

location ~ ^/internal_location_put(.*) {
   proxy_pass_request_body off;
   … complex and long location handler ...
}

location ~ ^/internal_location_other(.*) {
   … complex and long location handler ...
}

Thank you,

kuba

--

> On 06 Aug 2016, at 16:39, Maxim Dounin <mdounin at mdounin.ru> wrote:
> 
> Hello!
> 
> On Fri, Aug 05, 2016 at 10:14:36AM +0000, Jakub Moscicki wrote:
> 
>> Hello,
>> 
>> Would this kind of patch make sense to include in nginx upstream? If yes, then we would prepare it properly as an option (similar to proxy_pass_request_body).
>> 
>> Use-case: at CERN we use nginx as a reverse proxy for Webdav/HTTP access to our large-scale storage system (https://eos.readthedocs.io, https://eos.web.cern.ch) and in particular for Sync&Share service called CERNBox (https://www.researchgate.net/publication/288020928_CERNBox_EOS_end-user_storage_for_science).
>> 
>> All client file transfer requests (PUT and GET) are first passed to a metadata upstream server which performs an (internal) redirect to a (calculated) storage node (http upstream server).
>> 
>> In case of PUT we do not want and need to send the body to the metadata server but only to the storage node after internal X-Accel redirect. Hence, we have made this patch (on 1.6.2):
> 
> Consider using "proxy_pass_request_body off" instead, see 
> http://nginx.org/r/proxy_pass_request_body.
> 
> -- 
> Maxim Dounin
> http://nginx.org/
> 
> _______________________________________________
> nginx-devel mailing list
> nginx-devel at nginx.org
> http://mailman.nginx.org/mailman/listinfo/nginx-devel



More information about the nginx-devel mailing list