I. Why is the Nginx error page elegantly displayed?
When we access a website, errors such as 403,404,503 may occur frequently due to special reasons, which greatly affects the user's access experience. Therefore, it is necessary to make an elegant display of the error page, to improve the user's browsing experience.
Ii. How can I define an elegant display page in Nginx?
The following uses Error 404 as an example. The specific steps are as follows:
1. Create a website 404.html page and place it under the site directory;
2. Change the nginx. conf configuration file and add fastcgi_intercept_errors on to the http module;
3. Change the nginx. conf configuration file and add error_page 404/404 .html to the server module, or error_page 404 = http://www.hulala.com/404.html;
4. Check the syntax/nginx/sbin/nginx-t and restart nginx;
Now, the page with the 404 error is elegantly displayed and configured with OK.
To put it another way: other errors such as 502 and 403 can be configured in the same way.
Error_page 500 502 503 x.html;
Error_page 403/403 .html;
Note:
In nginx, the error redirection takes effect only when fastcgi_intercept_errors on is set and the error_page option is set correctly.
Recommended reading:
Configure and optimize reverse proxy and load balancing in Nginx
Nginx load balancing: nginx: [emerg] cocould not build the types_hash
Nginx Load Balancing module ngx_http_upstream_module details
Nginx + Firebug allows the browser to tell you which Server Load balancer distributes requests
Ubuntu install Nginx php5-fpm MySQL (LNMP environment setup)
Nginx details: click here
Nginx: click here