Random Error Pages to be served using nginx
Igor Sysoev
igor at sysoev.ru
Sat Dec 12 23:06:21 MSK 2009
On Sun, Dec 13, 2009 at 12:41:56AM +0530, Harish Sundararaj wrote:
> Hi all,
>
> I'm looking for a way to serve random error pages for 504/502 errors.
> In addition i also want the error pages to be served based on the
> $request_uri.
>
> Something like this:
> 1) When this URL is requested: http://mydomain.com/search?type=ABC
> and if the proxy returns a 504 or 502 and when the GET parameter 'type' has
> 'ABC' as value then serve
> any random document from "/path/to/custom/error/typeABC/"
>
> 2) and the same applies to http://mydomain.com/search?type=DEF just that the
> directory to be used to serve
> error document should be "/path/to/custom/error/typeDEF"
>
> I'm sure this can be achieved with named locations and probably try_files.
> But I'm just not able to get anything working.
>
> Would appreciate some pointers.
./configure --with-http_random_index_module
error_page 502 504 /error/type$arg_type/';
location = /error/typeABC/ {
root /path/to/custom/;
random_index on;
}
location = /error/typeDEF/ {
root /path/to/custom/;
random_index on;
}
# fallback
location /error/type {
root /path/to/custom/;
random_index on;
}
--
Igor Sysoev
http://sysoev.ru/en/
More information about the nginx
mailing list