I should also add that currently this works really well for every distinct $request_url by: location / { … error_page 500 502 503 504 /maintenance.html; … proxy_cache_valid 500 502 503 504 3m; } location = /maintenance.html { root /etc/nginx/static; }