nginx+lua reverse proxy empty body
agentzh
agentzh at gmail.com
Fri Nov 30 01:52:12 UTC 2012
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
More information about the nginx
mailing list