Welcome! Log In Create A New Profile

Advanced

Re: 502 from upstream not handled by nginx error_page

June 12, 2009 04:27PM
On Fri, Jun 12, 2009 at 04:15:24PM -0400, JamesHarrison wrote:

> Hi,
>
> I'm having issues serving up a custom 502 using upstream; essentially nginx's 502 is always shown, despite having a custom 502 page set up with error_page.
>
> The configuration is here: http://pastie.org/private/8kjglkprvw8pfoeqkjcbug
>
> I've tried this with proxy_intercept_errors on, off, in the location and server blocks. Sadly, no dice.
>
> Error logs show nothing but 2009/06/12 20:04:43 14569#0: *2 no live upstreams while connecting to upstream
>
> The file it's trying to serve from for the 502 page is in the same folder with the same permissions as the static data nginx hosts anyway.
>
> Any ideas why this 502 is being ignored?

You should use location, but not path in error_page:

error_page 502 /opt/www/charactr/current/public/502.html;

error_page 502 /502.html;

loction = /503.html {
# the root is iherited from server level
#root /opt/www/charactr/current/public/;
}

Instead of

location / {
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_redirect off;

if (-f $request_filename/index.html) {
rewrite (.*) $1/index.html break;
}

if (-f $request_filename.html) {
rewrite (.*) $1.html break;
}

if (!-f $request_filename) {
proxy_pass http://charactrapp;
break;
}
}

it's better to use

location / {
try_files $uri/index.html $uri.html $uri @charactrapp;
}

location @charactrapp {
proxy_pass http://charactrapp;

proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_redirect off;
}

Also, if you use 0.7.x, it's better to use

gzip_disable msie6;

instead of

gzip_disable "MSIE [1-6]\.";


--
Igor Sysoev
http://sysoev.ru/en/
Subject Author Posted

502 from upstream not handled by nginx error_page

JamesHarrison June 12, 2009 04:15PM

Re: 502 from upstream not handled by nginx error_page

Igor Sysoev June 12, 2009 04:27PM

Re: 502 from upstream not handled by nginx error_page

JamesHarrison June 12, 2009 05:27PM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 89
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