0

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?

0 Answers0