Hello!
On Thu, Sep 25, 2014 at 2:20 AM, Pradeep L wrote:
> I am developing a tool which will display all the request packets that nginx
> is getting .Now i am planning to display all the response packets that nginx
> gives .
This is gonna be quite expensive :) You've been warned.
> so i need to log all the response body to some log file .
> how do i achieve this using nginx lua module ?
If you really want to log all your response body data, you can use
body_filter_by_lua to write the data chunks to files as soon as they
arrive. This way you do not have to buffer all the response body data
in memory, which is very expensive for huge responses.
> i was able to capture the response body using ngx.location.capture().
This API buffers all the response body data in memory and for your use
case, you can avoid that. See above.
> what i need
> is that all the response body that the nginx sends should be logged
> regardless of location ..
Well, just use body_filter_by_lua or body_filter_by_lua_file in your
server {} level or even http {} level, then all the inner locations
will inherit this configuration.
Regards,
-agentzh