Handling upstream response 401

Maxim Dounin mdounin at mdounin.ru
Wed Jul 25 13:44:23 UTC 2018


Hello!

On Wed, Jul 25, 2018 at 01:14:29PM +0000, Friscia, Michael wrote:

> If the upstream server returns a 401 response I want to make 
> sure Nginx serves the response. Right now it is serving the 
> stale version. What happened is that the upstream page was 
> public but then made secure, so it sends back the 401 redirect 
> for browser login. Nginx is behaving properly in serving stale 
> but I want to change how it works just for 401. We do serve 
> stale for 404 because we don’t see a need to serve a fresh 
> response every time for content that doesn’t exist.

Are you sure you are seeng nginx returning a stale response on 401 
from the upstream server?

With proxy_cache_use_stale you can configure nginx to return stale 
responses on 500, 502, 503, 504, 403, 404, and 429 (see 
http://nginx.org/r/proxy_cache_use_stale).  It does not, however, 
return stale responses on 401.

Either you've did something very strange in your configuration, 
or you are trying to solve a problem which does not exist.

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


More information about the nginx mailing list