Welcome! Log In Create A New Profile

Advanced

Re: [PATCH] Stream: added extra variables for logging

Vladimir Homutov
July 13, 2020 05:08AM
13.07.2020 12:00, Hinel Balázs пишет:
> Ok, I agree on that one. How about the other one (internal interface
> address of nginx)?

same logic applies. If nginx failed to connect to one upstream server,
it will try next one, and local port (and address maybe too) will change.


>
> On Mon, Jul 13, 2020 at 10:54 AM Vladimir Homutov <vl@nginx.com> wrote:
>>
>> On Fri, Jul 10, 2020 at 06:10:44PM +0200, Hinel Balázs wrote:
>>> Hi,
>>> The first one (upstream_addr) contains the address and port in one
>>> single variable, but we need to put them separately into the access
>>> log, that's why we need the two variables. The second one
>>> (remote_addr) contains the client's address, which initiated the
>>> connection from outside. The third one also contains the client
>>> address, if I read correctly, and only if we would use the PROXY
>>> protocol (we don't). What we added here are the variables for address
>>> of the upstream, and the address of the internal interface of nginx,
>>> which is used to establish the connection towards the upstream.
>>>
>>> Best regards,
>>> Balazs
>>
>> Note that it should be relatively easy to extract address/port into
>> separate variables using map or njs/other scripting language, so
>> you don't need to program new variable each time.
>>
>> You may also want to look into implementation of the $upstream_addr
>> variable: it is located in the stream upstream module, and it is a
>> bit more complex than an addr:port pair, quoting the doc:
>>
>> If several servers were contacted during proxying, their addresses are
>> separated by commas, e.g. “192.168.1.1:12345, 192.168.1.2:12345, unix:/tmp/sock”.
>> If a server cannot be selected, the variable keeps the name of the
>> server group.
>>
>>>
>>>
>>> On Fri, Jul 10, 2020 at 4:03 PM Vladimir Homutov <vl@nginx.com> wrote:
>>>>
>>>> On Thu, Jul 09, 2020 at 04:20:16PM +0200, Balazs Hinel wrote:
>>>>> # HG changeset patch
>>>>> # User Balazs Hinel <balazs.hinel@nokia.com>
>>>>> # Date 1594225255 -7200
>>>>> # Wed Jul 08 18:20:55 2020 +0200
>>>>> # Node ID ab1359d9762109d1cccb06fbe85e17168b51ebed
>>>>> # Parent 2ab0ecfe5a5f02f7214b02c8a1f9d6c5843d310e
>>>>> Stream: added extra variables for logging.
>>>>>
>>>>> As a result, the local and remote connection details (address and port)
>>>>> used in the upstream connection can be logged.
>>>>>
>>>>> diff -r 2ab0ecfe5a5f -r ab1359d97621 src/stream/ngx_stream.h
>>>>> --- a/src/stream/ngx_stream.h Tue Jul 07 18:56:06 2020 +0300
>>>>> +++ b/src/stream/ngx_stream.h Wed Jul 08 18:20:55 2020 +0200
>>>>> @@ -192,6 +192,14 @@
>>>>> } ngx_stream_core_srv_conf_t;
>>>>>
>>>>
>>>> Hello and thank you for contribution!
>>>>
>>>> What problem are you trying to solve and why existing variables
>>>>
>>>> http://nginx.org/en/docs/stream/ngx_stream_upstream_module.html#var_upstream_addr
>>>> http://nginx.org/en/docs/stream/ngx_stream_core_module.html#var_remote_addr
>>>> http://nginx.org/en/docs/stream/ngx_stream_realip_module.html#var_realip_remote_addr
>>>>
>>>> are not enough?
>>>>
>>>> Note also that we log connection events in the error log at INFO level in the
>>>> stream module.
>>>> _______________________________________________
>>>> nginx-devel mailing list
>>>> nginx-devel@nginx.org
>>>> http://mailman.nginx.org/mailman/listinfo/nginx-devel
>>> _______________________________________________
>>> nginx-devel mailing list
>>> nginx-devel@nginx.org
>>> http://mailman.nginx.org/mailman/listinfo/nginx-devel
>> _______________________________________________
>> nginx-devel mailing list
>> nginx-devel@nginx.org
>> http://mailman.nginx.org/mailman/listinfo/nginx-devel
> _______________________________________________
> nginx-devel mailing list
> nginx-devel@nginx.org
> http://mailman.nginx.org/mailman/listinfo/nginx-devel
>

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

[PATCH] Stream: added extra variables for logging

Balazs Hinel 125 July 09, 2020 10:22AM

Re: [PATCH] Stream: added extra variables for logging

Vladimir Homutov 18 July 10, 2020 10:04AM

Re: [PATCH] Stream: added extra variables for logging

Hinel Balázs 17 July 10, 2020 12:12PM

Re: [PATCH] Stream: added extra variables for logging

Vladimir Homutov 12 July 13, 2020 04:54AM

Re: [PATCH] Stream: added extra variables for logging

Hinel Balázs 12 July 13, 2020 05:02AM

Re: [PATCH] Stream: added extra variables for logging

Vladimir Homutov 17 July 13, 2020 05:08AM



Sorry, you do not have permission to post/reply in this forum.

Online Users

Guests: 101
Record Number of Users: 6 on February 13, 2018
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready