Welcome! Log In Create A New Profile

Advanced

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

jb
April 17, 2015 09:46PM
ok I figured it out, I proxy_pass to nginx

but I still have the same issue with aborted connection and bytes read :)

Here is my custom_log format:

.... $body_bytes_sent rl=$request_length cl=$content_length ...

Here is an example POST using proxy_pass to 127.0.0.1

.... "POST /upload HTTP/1.1" 200 26 rl=456 cl=9885416 rt=15.874 ...

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.

thanks

On Sat, Apr 18, 2015 at 11:23 AM, jb <justinbeech@gmail.com> wrote:

> gotcha, I saw the discarded body thing in the debug log. ok thanks,
> um, how do you proxy_pass to nginx itself ?
>
> can you give an example ?
> just proxy_pass http://127.0.0.1/
> and proxy_pass_request_body off
>
> what about my return 200 "$content_length bytes" line still keep that?
>
>
> On Sat, Apr 18, 2015 at 11:10 AM, Valentin V. Bartenev <vbart@nginx.com>
> wrote:
>
>> 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
>>
>
>
_______________________________________________
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: 185
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