Welcome! Log In Create A New Profile


Trying to config for proxying to site down page

Daniel Earle
May 13, 2022 10:28AM
I'm trying to get nginx to forward to my S3 bucket when my web app k8 pod
is down. So I was hoping the below config would, in the case of 50x error
or no response, forward request to bucket, then if the document doesn't
exist (very likely for first 50x request) - it would then return
sitedown.html - this would then request some css files which would fail
with same 50x then try on S3 and success.

However it just returns 404 when my application pod is down (if I remove
proxy_intercept_errors on; error_page 403 404 =200 I get the S3 404
message as expected).

I want to avoid hosting the website down error page on the nginx server.

Below is my config (everything else config wise is as in the FROM
nginxinc/nginx-unprivileged:1.21 docker image)

server {
listen 8080 default_server;
server_name _;
port_in_redirect off;
client_max_body_size 51M;
server_tokens off;

error_page 501 502 503 504 = @holding_page_proxy;

location @holding_page_proxy {
proxy_intercept_errors on;
error_page 403 404 =200

location / {
proxy_read_timeout 180s;
proxy_set_header X-Real-IP $http_x_real_ip;
proxy_set_header X-Forwarded-Host "";
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_next_upstream error timeout invalid_header http_502
http_503 http_504 http_404;
proxy_http_version 1.1;
proxy_pass http://application:8080/;

# Deny access to the Spring Boot actuator.
location /actuator {
deny all;

# probe for kubernetes checks
location = /probe.html {
root /usr/share/nginx/html;
nginx mailing list -- nginx@nginx.org
To unsubscribe send an email to nginx-leave@nginx.org
Subject Author Posted

Trying to config for proxying to site down page

Daniel Earle May 13, 2022 10:28AM

RE: Trying to config for proxying to site down page

Reinis Rozitis May 14, 2022 11:58AM

Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 67
Record Number of Users: 6 on February 13, 2018
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready