(reproduced) http://www.cnblogs.com/jiangyao/archive/2010/07/10/1774981.html
1.Create your own 404.html page
2.Change nginx.conf in the HTTP definition area:fastcgi_intercept_errors on;
3.Change nginx.conf (or separate site profile, for example, in NginxSitesSite configuration file under-enabled)
In the server zone join:error_page 404/404.htmlorerror_page 404 =http://www.xxx.com/404.html
4.Restart nginx after change, test nginx.conf correctness:/opt/nginx/sbin/nginx–t
errors such as #502 can be configured in the same way.
Error_page 502 503 504/50x.html;
Precautions :
1. You must add: fastcgi_intercept_errors on; If this option is not set, even if 404.html is created and Error_page is configured, there is no effect. Fastcgi_intercept_errors syntax: fastcgi_intercept_errors on|off default: fastcgi_intercept_errors off Add Location: http, server, Location by default, Nginx does not support custom 404 error pages, and only this instruction is set to On,nginx to support 404 error redirection. It is important to note that it is not said that setting the Fastcgi_intercept_errors On,nginx will redirect the 404 error. In Nginx, 404 error redirection takes effect if fastcgi_intercept_errors on is set and the Error_page option is set correctly (including syntax and corresponding 404 pages)
2. Do not for the sake of convenience or improve the purpose of home page weight to designate the homepage as 404 error page, do not use other methods to jump to the homepage.
3. The custom 404 page must be greater than 512 bytes, otherwise the IE default 404 page may appear. For example, suppose you have customized 404.html with a size of only 11 bytes (content: 404 error).
Nginx 404 50x Configuration (reprint)