Configuration of the Nginx error page for elegant display

Source: Internet
Author: User
Tags nginx load balancing

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.