Welcome! Log In Create A New Profile

Advanced

Re: N00b - logging stream request / response

All files from this thread

File Name File Size   Posted by Date  
nginx.conf 1.6 KB open | download Joel Parker 04/25/2017 Read message
Robert Paprocki
April 25, 2017 02:40PM
What you're doing doesn't quite make sense. You're trying to log HTTP data
inside a stream block. That doesn't work. There's no such concept of
$status, $http_referer, etc, inside a stream {} block.

Have a read of the log_format docs:
http://nginx.org/en/docs/http/ngx_http_log_module.html#log_format


Syntax: *log_format* *name* [escape=default|json] *string* ...;
Default:

log_format combined "...";

Context: http



On Tue, Apr 25, 2017 at 11:32 AM, Joel Parker <joel.parker.gm@gmail.com>
wrote:

> I am trying to log all request / response in a stream with a lua script I
> found in git hub and am having issues figuring out where to put the
> log_format directive. Here is what I currently have :
>
> stream {
>
> log_format bodylog '$remote_addr - $remote_user [$time_local] '
> '"$request" $status $body_bytes_sent '
> '"$http_referer" "$http_user_agent" $request_time '
> '<"$request_body" >"$resp_body"';
>
> lua_need_request_body on;
>
> set $resp_body "";
> body_filter_by_lua '
> local resp_body = ngx.arg[1]
> ngx.ctx.buffered = (ngx.ctx.buffered or "") .. resp_body
> if ngx.arg[2] then
> ngx.var.resp_body = ngx.ctx.buffered
> end
> ';
>
> ......
>
> }
>
> _______________________________________________
> 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

N00b - logging stream request / response

Joel Parker April 25, 2017 02:34PM

Re: N00b - logging stream request / response

Robert Paprocki April 25, 2017 02:40PM

Re: N00b - logging stream request / response

Joel Parker April 25, 2017 02:48PM

Re: N00b - logging stream request / response

Robert Paprocki April 25, 2017 02:50PM

Re: N00b - logging stream request / response

Joel Parker April 25, 2017 02:54PM

Re: N00b - logging stream request / response

Robert Paprocki April 25, 2017 03:02PM

Re: N00b - logging stream request / response Attachments

Joel Parker April 25, 2017 03:12PM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

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