Score:0

Built header value not working

tl flag

I am building an Authorization header before forwarding the request to the proper service. The token is being passed to Nginx as a query string parameter named custom.

Here is the thing:

set $auth_header 'Bearer $arg_custom';
proxy_set_header Authorization $auth_header;
proxy_pass http://grafana;

When doing so, Grafana returns Invalid Basic Auth Header. But it works fine if I hard-code the header value, like this:

proxy_set_header Authorization "Bearer jg598jmg9584jm09ey4";

I already know Nginx builds the value correctly, because I can see it with this response header:

add_header X-Token $auth_header;

Security concerns aside, it seems pretty obvious that Nginx sets the Authorization value correctly when hardcoded, but not when taken from a variable or using string interpolation.

Any suggestion?

I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.