Caching result of auth_request_set?

jarstewa nginx-forum at forum.nginx.org
Fri Jul 20 19:42:40 UTC 2018


I'm currently using the auth_request directive and caching the result based
on a guid + IP address: 

>location /auth { 
>    internal;
>
>    proxy_pass_request_body off;
>    proxy_pass $upstream_server/auth?id=$guid&requestor=$last_client_ip;
>
>    proxy_cache auth_cache;
>    set $auth_cache_key "${guid}|${last_client_ip}";
>    proxy_cache_key $auth_cache_key;
>    proxy_cache_valid 200 301 302 5m;
>    proxy_cache_valid 401 403 404 5m;
>
>} 

It would be very convenient for me to return back a bit of metadata
associated with the guid from the upstream auth request, and send that bit
of metadata along with the actual request that will follow if the auth
subrequest succeeds.  It looks like this is possible via the
auth_request_set directive, but I am not sure how auth_request_set would
interact with proxy_cache.

For auth requests, is proxy cache only caching the HTTP response code?  Or
is it caching the full response including variables?  In other words, will
auth_request_set still work correctly to set a variable when the auth
response is cached?  Thank you!

Posted at Nginx Forum: https://forum.nginx.org/read.php?2,280590,280590#msg-280590



More information about the nginx mailing list