Welcome! Log In Create A New Profile

Advanced

Re: logging variables -- $bytes_sent .. where is $bytes_read ?

Valentin V. Bartenev
April 17, 2015 09:12PM
On Saturday 18 April 2015 10:24:17 jb wrote:
> And maybe I am approaching this the wrong way? can you comment..
>
> I want an nginx upload target for POST that reads the content, discards it,
> and reports the amount read. This is what I have in essence:
>
> location ~* "/upload" {
> limit_except POST OPTIONS { deny all; }
> client_max_body_size 0;
> add_header Cache-Control "max-age=0, no-cache, no-store, must-revalidate";
> keepalive_timeout 0;
> add_header Content-Type 'text/html';

This just adds duplicate "Content-Type" header.
See the "default_type" directive: http://nginx.org/r/default_type


> return 200 '$content_length bytes';
> }
>
> The uploads are being done with XHR on the browser side. It works, however
> randomly (less than 1% of cases), browsers fail during the POST: they
> return xhr with readyState 4 but status 0, and only a partial upload
> progress recorded.
> On the server side, no error is generated in error_log, and access_log
> reports status 200.
>
> $request_length is very short, just the header of the upload.
>
> I am wondering if this is mis-use of upload handling by nginx. However I do
> not want to setup an upstream server to receive the POST content, it is to
> be discarded anyway.
>
> Is there a more correct way to handle POST within nginx, with a response
> after all data is read, but without an upstream server?
>
[..]

Oh, ok I see what happens. Indeed, the $request_length isn't accounted if
you discard request body this way.

The workaround can be using proxy_pass to nginx itself. You don't need
to pass body however: http://nginx.org/r/proxy_pass_request_body

wbr, Valentin V. Bartenev

_______________________________________________
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx
Subject Author Posted

logging variables -- $bytes_sent .. where is $bytes_read ?

jb April 17, 2015 06:24PM

Re: logging variables -- $bytes_sent .. where is $bytes_read ?

Valentin V. Bartenev April 17, 2015 07:48PM

Re: logging variables -- $bytes_sent .. where is $bytes_read ?

jb April 17, 2015 08:10PM

Re: logging variables -- $bytes_sent .. where is $bytes_read ?

jb April 17, 2015 08:26PM

Re: logging variables -- $bytes_sent .. where is $bytes_read ?

Valentin V. Bartenev April 17, 2015 09:12PM

Re: logging variables -- $bytes_sent .. where is $bytes_read ?

jb April 17, 2015 09:26PM

Re: logging variables -- $bytes_sent .. where is $bytes_read ?

jb April 17, 2015 09:46PM

Re: logging variables -- $bytes_sent .. where is $bytes_read ?

Valentin V. Bartenev April 17, 2015 10:08PM

Re: logging variables -- $bytes_sent .. where is $bytes_read ?

jb April 17, 2015 10:18PM

Re: logging variables -- $bytes_sent .. where is $bytes_read ?

Valentin V. Bartenev April 17, 2015 08:56PM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 169
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready