Variable “set” in map with an Header Value was lost when we delete the header.

podzol33 nginx-forum at
Wed Jan 12 17:44:34 UTC 2022


We have an responseHeader with technical information sent by the upstream
server tomcat.
We want to log this information in nginx and delete the header to avoid to
be visible in the response Header to the client.

log_format formatjson escape=json '{ 
    '"tomcat_container_id": "$TOMCAT_CONTAINER_ID" }';

Nginx.conf in http {
map $sent_http_Container_Id $TOMCAT_CONTAINER_ID {
    default $sent_http_Container_Id;
more_clear_headers 'Container-Id';

When I do this, my log tomcat_container_id is empty. 
If I comment the more_clear_header command line, I have my log fill with the
right value but the header is also sent to the client.
So I don’t understand why my $TOMCAT_CONTAINER_ID Is clear when I delete the
header and not clear if I don’t.

Thanks for your help.

Posted at Nginx Forum:,293336,293336#msg-293336

More information about the nginx mailing list