Caching result of auth_request_set?

Maxim Dounin mdounin at mdounin.ru
Sun Jul 22 02:52:14 UTC 2018


Hello!

On Fri, Jul 20, 2018 at 03:42:40PM -0400, jarstewa wrote:

> 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!

Unless it is specifically instructed to intercept errors using the 
proxy_intercept_errors directive, proxy cache caches full response 
as get from the upstream server.  That is, auth_request_set is 
expected to work just fine.

-- 
Maxim Dounin
http://mdounin.ru/


More information about the nginx mailing list