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

Jakub Moscicki Jakub.Moscicki at cern.ch
Fri Aug 5 10:14:36 UTC 2016


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):

--- a/src/http/ngx_http_upstream.c      2015-01-27 16:24:56.000000001 +0100
+++ b/src/http/ngx_http_upstream.c      2014-09-16 14:23:20.000000001 +0200
@@ -525,8 +525,10 @@ ngx_http_upstream_init_request(ngx_http_
         r->write_event_handler = ngx_http_upstream_wr_check_broken_connection;

-    if (r->request_body) {
-        u->request_bufs = r->request_body->bufs;
+    if (r->method != NGX_HTTP_PUT) {
+      if (r->request_body) {
+      u->request_bufs = r->request_body->bufs;
+      }

     if (u->create_request(r) != NGX_OK) {

Thank you for your comments.

Jakub Moscicki & Andreas Peters

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.nginx.org/pipermail/nginx-devel/attachments/20160805/ada770a1/attachment.html>

More information about the nginx-devel mailing list