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
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:
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;
Type: Come in three options, i.e. HTML source code, backend URL address, and existing HTML file in Global Static File;
Content Type of Response Header: The default setting is
, which can be changed as needed;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
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' 126.96.36.199/404.html
HTTP/1.1 404 Not Found
Date: Fri, 31 Aug 2018 09:16:39 GMT
Content-Type: text/html; charset=utf8
As expected, the response body is the preset hello
rather than the
default 404 page.