# Custom Error Page

Setting a custom 404 or 500 error page

is a function supported in OpenResty Edge.

Directly create a Page Rules to see how to use the function which belongs to Page Rules in application.

The Action drop-down list offers many options. Drop down to the bottom “Others” and select Customize error page.

A custom error page contains four user-defined parameters:

  1. Error Code: Select HTTP error codes that are returned to the custom page. Only the several 4xx and 5xx error codes listed in the page are optional;

  2. Type: Come in three options, i.e. HTML source code, backend URL address, and existing HTML file in Global Static File;

  3. Content Type of Response Header: The default setting is text/html; charset=utf8, which can be changed as needed;

  4. Content of Response Body: Content varies depending on the type selected.

Here is a very simple example. The custom 404 error response body is character string hello:

With no conditions imposed on this rule, just click the Create button on the bottom right-hand side.

Now, verify whether the limit rule works or not.

First, enter the Release page to synchronize this rule to nodes of all gateways.

With the release, Release can be viewed. No further explanation is necessary.

Then, open shell to simulate client-side access.

$ curl -i -H 'host: rewrite-rule-test.com'

HTTP/1.1 404 Not Found

Server: openresty+

Date: Fri, 31 Aug 2018 09:16:39 GMT

Content-Type: text/html; charset=utf8

Transfer-Encoding: chunked

Connection: keep-alive


As expected, the response body is the preset hello rather than the default 404 page.