<div dir="ltr">ok I figured it out, I proxy_pass to nginx<div><br><div>but I still have the same issue with aborted connection and bytes read :)</div><div><br></div><div>Here is my custom_log format:</div><div><br></div>... $body_bytes_sent rl=$request_length cl=$content_length ...<br><br>Here is an example POST using proxy_pass to 127.0.0.1<br><br>... "POST /upload HTTP/1.1" 200 26 rl=456 cl=9885416 rt=15.874 ...<br><br>You can see request_length is only 456 bytes, and content_length is 9.9mb however the request was aborted after 15 seconds and some OTHER number of bytes were read, some number between those two figures. 9885416 was the number given by the client.</div><div><br></div><div>thanks</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Sat, Apr 18, 2015 at 11:23 AM, jb <span dir="ltr"><<a href="mailto:justinbeech@gmail.com" target="_blank">justinbeech@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">gotcha, I saw the discarded body thing in the debug log. ok thanks,<div>um, how do you proxy_pass to nginx itself ?<br></div><div><div><br></div><div>can you give an example ?</div></div><div>just proxy_pass <a href="http://127.0.0.1/" target="_blank">http://127.0.0.1/</a> </div><div>and proxy_pass_request_body off</div><div><br></div><div>what about my return 200 "$content_length bytes" line still keep that?</div><div><br></div></div><div class="HOEnZb"><div class="h5"><div class="gmail_extra"><br><div class="gmail_quote">On Sat, Apr 18, 2015 at 11:10 AM, Valentin V. Bartenev <span dir="ltr"><<a href="mailto:vbart@nginx.com" target="_blank">vbart@nginx.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span>On Saturday 18 April 2015 10:24:17 jb wrote:<br>
> And maybe I am approaching this the wrong way? can you comment..<br>
><br>
> I want an nginx upload target for POST that reads the content, discards it,<br>
> and reports the amount read. This is what I have in essence:<br>
><br>
> location ~* "/upload" {<br>
>   limit_except POST OPTIONS { deny all; }<br>
>   client_max_body_size 0;<br>
>   add_header Cache-Control "max-age=0, no-cache, no-store, must-revalidate";<br>
>   keepalive_timeout 0;<br>
>   add_header Content-Type 'text/html';<br>
<br>
</span>This just adds duplicate "Content-Type" header.<br>
See the "default_type" directive: <a href="http://nginx.org/r/default_type" target="_blank">http://nginx.org/r/default_type</a><br>
<span><br>
<br>
>   return 200 '$content_length bytes';<br>
> }<br>
><br>
> The uploads are being done with XHR on the browser side. It works, however<br>
> randomly (less than 1% of cases), browsers fail during the POST: they<br>
> return xhr with readyState 4 but status 0, and only a partial upload<br>
> progress recorded.<br>
> On the server side, no error is generated in error_log, and access_log<br>
> reports status 200.<br>
><br>
> $request_length is very short, just the header of the upload.<br>
><br>
> I am wondering if this is mis-use of upload handling by nginx. However I do<br>
> not want to setup an upstream server to receive the POST content, it is to<br>
> be discarded anyway.<br>
><br>
> Is there a more correct way to handle POST within nginx, with a response<br>
> after all data is read, but without an upstream server?<br>
><br>
</span>[..]<br>
<br>
Oh, ok I see what happens.  Indeed, the $request_length isn't accounted if<br>
you discard request body this way.<br>
<br>
The workaround can be using proxy_pass to nginx itself.  You don't need<br>
to pass body however: <a href="http://nginx.org/r/proxy_pass_request_body" target="_blank">http://nginx.org/r/proxy_pass_request_body</a><br>
<div><div><br>
  wbr, Valentin V. Bartenev<br>
<br>
_______________________________________________<br>
nginx mailing list<br>
<a href="mailto:nginx@nginx.org" target="_blank">nginx@nginx.org</a><br>
<a href="http://mailman.nginx.org/mailman/listinfo/nginx" target="_blank">http://mailman.nginx.org/mailman/listinfo/nginx</a><br>
</div></div></blockquote></div><br></div>
</div></div></blockquote></div><br></div>