参考官方提供的文档:
http://wiki.nginx.org/HttpCoreModule#error_page
error_page
Syntax: error_page code ... [ = [ response ]] uri
Default:
Context: http
server
location
if in location
Reference: error_page
The directive specifies the URI that will be shown for the errors indicated.
Example:
error_page 404 /404.html;
error_page 502 503 504 /50x.html;
error_page 403
http://example.com/forbidden.html;
error_page 404 = @fetch;
Furthermore, it is possible to change the status code of the answer to another, for example:
error_page 404 =200 /empty.gif;
error_page 404 =403 /forbidden.gif;
Additionally you can have your designated error handler determine the returned status code by using = without specifying a status code.
error_page 404 = /404.php;
If there is no need to change URI during redirection it is possible to redirect processing of error pages into a named location:
location / (
error_page 404 @fallback;
)
location @fallback (
proxy_pass
http://backend;
)