I'm using auth_request along with a proxy cache. The caching itself seems to be working, but I wanted to add an extra layer of visibility by adding a header to the final request with the auth request cache status using $upstream_cache_status in the auth request.
However, I haven't been able to access any of the headers I added using auth_request_set. The $upstream_http_header_name variables always seems to stay empty even if I just add a static header, so this doesn't seem to be related to the $upstream_cache_status itself.
Below is a snippet of some of the relevant config. I'm still very new to NGINX so maybe I'm doing something wrong? Maybe there's another way to get the cache status from an auth_request?
Would appreciate any ideas from folks who are more experienced and knowledgeable. Thanks!
location @request {
auth_request /auth;
auth_request_set $cache_status_auth $upstream_http_r_cache_status_auth;
auth_request_set $test $upstream_http_test;
...
}
location /auth {
internal;
proxy_pass http://host.docker.internal:58090/$auth_query;
proxy_pass_request_body off;
proxy_cache auth_cache;
proxy_cache_key "$auth_query";
proxy_cache_use_stale error timeout updating http_502 http_503 http_504;
proxy_cache_background_update on;
proxy_cache_lock on;
proxy_cache_lock_timeout 1s;
proxy_http_version 1.1;
proxy_set_header Connection "";
# FIXME: this doesn't seem to actually work. $upstream_http_r_cache_status_auth doesn't end up getting populated?
add_header r-cache-status-auth $upstream_cache_status;
# FIXME: even this doesn't seem to work? nothing in $upstream_http_test either.
add_header test "test";
}