Andrey Kopeyko
May 22, 2021 08:58PM
Gena Makhomed писал 2021-05-23 01:50:
> On 23.05.2021 1:25, Andrey Kopeyko wrote:
>
>> Добрый день, Геннадий!
>
> Здравствуйте, Андрей!
>
>>> Использую nginx/1.19.10 из официального репозитория nginx.org
>>>
>>> На бэкенде в секции http прописал такие директивы:
>>>
>>> add_trailer X-Response-Time $upstream_response_time always;
>>> add_trailer X-Cache-Status $upstream_cache_status always;
>>>
>>> На фронтенде в секции http прописал proxy_http_version 1.1;
>>> Также на фронтенде в директиву log_format добавил переменные:
>>>
>>> $upstream_trailer_x_response_time $upstream_trailer_x_cache_status
>>>
>>> Ожидается что в лог будут записаны полученные значения этих
>>> переменных,
>>> но вместо них в лог пишутся символы - - обозначающие пустые значения.
>>>
>>> Почему так происходит?
>>
>> Очевидно, потому что бэкенд _не_ возвращал вам заголовков
>> "trailer-x-response-time: " - вы их сами выдумали.
>
> trailer fields at the end of the message - это не заголовки.
>
> Бэкенд эти trailers возвращает, я проверял переменные
>
> $sent_trailer_x_response_time $sent_trailer_x_cache_status
>
> на бэкенде они имеют не пустые значения и пишутся в лог бэкенда.

Стало понятнее.

Предположу, что в переменные $upstream_ они не попадают, т.к. передаются
бэкендом _после_ тела ответа, а заголовки nginx ожидает увидеть _до_
тела.



--
Best regards,
Andrey A. Kopeyko <andrey@kopeyko.ru>
_______________________________________________
nginx-ru mailing list
nginx-ru@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx-ru
Subject Author Posted

How to write $upstream_trailer_{name} into access.log

Gena Makhomed May 22, 2021 06:02PM

Re: How to write $upstream_trailer_{name} into access.log

Andrey Kopeyko May 22, 2021 06:26PM

Re: How to write $upstream_trailer_{name} into access.log

Gena Makhomed May 22, 2021 06:52PM

Re: How to write $upstream_trailer_{name} into access.log

Andrey Kopeyko May 22, 2021 08:58PM

Re: How to write $upstream_trailer_{name} into access.log

Andrey Kopeyko May 22, 2021 09:06PM

Re: How to write $upstream_trailer_{name} into access.log

Maxim Dounin May 23, 2021 09:20PM

Re: How to write $upstream_trailer_{name} into access.log

Илья Шипицин May 23, 2021 11:42PM

Re: How to write $upstream_trailer_{name} into access.log

Gena Makhomed May 25, 2021 04:08AM

Re: How to write $upstream_trailer_{name} into access.log

Maxim Dounin May 25, 2021 08:02AM

add_header

Gena Makhomed May 25, 2021 09:44AM

Re: add_header

Илья Шипицин May 25, 2021 09:54AM

Re: add_header

Maxim Dounin May 25, 2021 10:50AM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

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