Welcome! Log In Create A New Profile

Advanced

Re: nginx+lua reverse proxy empty body

agentzh
November 29, 2012 08:54PM
Hello!

On Wed, Nov 28, 2012 at 7:28 AM, Bart van Deenen wrote:
> Hi Agentz
>

Agentz is not my name, don't call me that. You can either call me
agentzh or Yichun.

> But wouldn't the statement
> client_body_in_single_buffer on;
> cause the whole body of the proxied server to go into ngx.arg[1] ?
>

client_body_in_single_buffer is for *request* bodies while
body_filter_by_lua is for *response* bodies. Please do not confuse
these two bodies. They're completely different things.

> And I also don't understand that my example code shouldn't work reliably, even if the proxied data is passed through it in chunks (unless the chunk boundary would accidentally be right in the middel of my short match string).

Yes, I mean exactly the case that the chunk boundary is in the middle
of your string. It could happen.

> I've done a very similar setup proxying and modification of a simple website (vandeenensupport.com), and that works perfectly.
>

Working 99.9% of the time can never imply 100% perfection :) This is
just a caveat :)

> I have also noticed that when I add a 'print(ngx.arg[1])' in the first line of the lua section of my example, the html replacement works reliably, no more empty ngx.arg[1]!

ngx.arg[1] could be an empty string by design, as explained in my
previous email. Always be prepared for that if you want your code
works reliably.

You can always reproduce a "special buf" (with empty data chunk) with
ngx_lua's ngx.flush() and ngx.eof() primitives.

> But that print only goes into the nginx logging, so maybe it's only its timing that has some effect?
>

Maybe.

Best regards,
-agentzh

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

nginx+lua reverse proxy empty body

Bart van Deenen November 27, 2012 05:30AM

Re: nginx+lua reverse proxy empty body

agentzh November 27, 2012 06:44PM

RE: nginx+lua reverse proxy empty body

Bart van Deenen November 28, 2012 10:30AM

Re: nginx+lua reverse proxy empty body

agentzh November 29, 2012 08:54PM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 189
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