Welcome! Log In Create A New Profile

Advanced

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

Zev Blut
October 27, 2009 11:52PM
Hi Phillip,

On 10/27/2009 05:02 PM, Phillip Oldham wrote:
> How about this (not tested)?
>> error_page 503 @maintenance;
>>
>> location @maintenance {
>> auth_basic off;
>> root /var/www/foobar/nginx_error_test/system;
>>
>> if ($content_type ~* javascript) {
>> rewrite . /system/maintenance.json last;
>> }
>>
>> if ($content_type ~* xml) {
>> rewrite . /system/maintenance.xml last;
>> }
>>
>> rewrite . /system/maintenance.html last;
>> }
>>
>> if (-f $request_filename) {
>> break;
>> }
>>
>> if (-f $request_filename.html) {
>> rewrite (.*) $1.html last;
>> }
>>
>> }

This is almost there!

Now when I do a request I will get the proper Content-Type response:

wget --header "Content-Type: application/javascript" -S -O -
errortest.localhost/index.json
--12:40:31-- http://errortest.localhost/index.json
=> `-'
Resolving errortest.localhost... 127.0.0.3
Connecting to errortest.localhost|127.0.0.3|:80... connected.
HTTP request sent, awaiting response...
HTTP/1.1 503 Service Temporarily Unavailable
Server: nginx/0.6.35
Date: Wed, 28 Oct 2009 03:40:31 GMT
Content-Type: application/javascript
Content-Length: 102
Connection: keep-alive
12:40:31 ERROR 503: Service Temporarily Unavailable.


But unfortunately, the output is not my maintenance.json output, it is
nothing in the case of wget and the default 500 internal server error in
a browser. Interestingly enough, the Content-Length is correct for the
maintenance.(json|xml|html) for the proper setting.

Any ideas why it would not show the rewritten maintenance page?

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: 176
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