[PATCH] Stream: added extra variables for logging
Vladimir Homutov
vl at nginx.com
Mon Jul 13 09:06:28 UTC 2020
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 at 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 at nginx.com> wrote:
>>>>
>>>> On Thu, Jul 09, 2020 at 04:20:16PM +0200, Balazs Hinel wrote:
>>>>> # HG changeset patch
>>>>> # User Balazs Hinel <balazs.hinel at 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 at nginx.org
>>>> http://mailman.nginx.org/mailman/listinfo/nginx-devel
>>> _______________________________________________
>>> nginx-devel mailing list
>>> nginx-devel at nginx.org
>>> http://mailman.nginx.org/mailman/listinfo/nginx-devel
>> _______________________________________________
>> nginx-devel mailing list
>> nginx-devel at nginx.org
>> http://mailman.nginx.org/mailman/listinfo/nginx-devel
> _______________________________________________
> nginx-devel mailing list
> nginx-devel at nginx.org
> http://mailman.nginx.org/mailman/listinfo/nginx-devel
>
More information about the nginx-devel
mailing list