nginx error redirect

    location / {
        proxy_pass http://some_servers;
        proxy_redirect          off;
        proxy_next_upstream     error timeout invalid_header http_500 http_404;
        proxy_connect_timeout   2;
        proxy_set_header        Host            $host;
        proxy_set_header        X-Real-IP       $remote_addr;
        proxy_set_header        X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_intercept_errors  on;
    }


    # redirect server error pages to the static page /50x.html
    error_page   502 503 504  /50x.html;
    # redirect server error 501 to 500 error with response of /500.html
    error_page   501 =500  /500.html;
    location = /50x.html {
        root   /usr/share/nginx/html;
    }
    location = /500.html {
        return 500 <b>Internal Error.<b>;
    }

 

LEAVE A COMMENT