Welcome! Log In Create A New Profile

Advanced

Suggestions on how to have error pages based on content type

Zev Blut
October 24, 2009 04:38AM
Hello,

I am wondering if it is possible to serve up error pages based on the
content type.

I.e. I want to show a different 503 error page for html, xml and
javascript content types.

I have tried to do something like this (with Nginx 0.6 series):
---------------------------

server {
listen 80;

charset off;
server_name errortest.localhost;

root /var/www/foobar/nginx_error_test;

if (-f /var/www/foobar/nginx_error_test/maintenance_on.html) {
rewrite ^(/images/.*)$ /images/server-maintenance.png break;
return 503;
break;
}

error_page 503 /system/maintenance;

location = /system/maintenance {
auth_basic off;
root /var/www/foobar/nginx_error_test/system;

if ($content_type ~* javascript) {
rewrite . /system/maintenance.json break;
}

if ($content_type ~* xml) {
rewrite . /system/maintenance.xml break;
}

rewrite . /system/maintenance.html break;
}

if (-f $request_filename) {
break;
}

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

}

---------------------------

Unfortunately, this does not work. All that happens is I get the
standard Nginx 503 html error response.

Any ideas if I can do this and if so what I am doing wrong?

Thanks,
Zev
Subject Author Posted

Suggestions on how to have error pages based on content type

Zev Blut October 24, 2009 04:38AM

Re: Suggestions on how to have error pages based on content type

Zev Blut October 26, 2009 10:16PM

Re: Suggestions on how to have error pages based on content type

Phillip Oldham October 27, 2009 04:06AM

Re: Suggestions on how to have error pages based on content type

Zev Blut October 27, 2009 11:52PM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 304
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready