In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly explains the "Nginx how to configure 404 pages", the content of the article is simple and clear, easy to learn and understand, now please follow the editor's ideas slowly in depth, together to study and learn "Nginx how to configure 404 pages" bar!
The first: Nginx's own error page
Nginx visits a static html page, and when the page is not available, Nginx throws 404, so how do you return it to the client?
Take a look at the configuration below, in which case you don't need to modify any parameters to achieve this function.
Server {listen 80th serverpage name www.test.com;root / var/www/test;index index.html index.htm;location / {} # defines the error page number, and if the corresponding error page number occurs, forward it there. Error_page 404, 403, 500, 502, 503, 504 / 404. Htmlwitt # inherits the above location. Location = / 404.html {# the directory path where the error page is placed. Root / usr/share/nginx/html;}} the second kind: error page of reverse proxy
If the backend Tomcat process throws a 404 error, and you want to call Nginx to feedback this status to the client or redirect to a connection, configure as follows:
Upstream www {server 192.168.1.201 server 7777 weight=20 max_fails=2 fail_timeout=30s;ip_hash;} server {listen 80th serveraccounname www.test.com;root / var/www/test;index index.html index.htm;location / {if ($request_uri ~ *'^ / $') {rewrite. * http://www.test.com/index.html redirect } # key parameters: only when this variable is enabled can we customize the error page. When the backend returns 404 http://www;proxy_set_header Nginx intercept error definition error page proxy_intercept_errors on;proxy_pass http://www;proxy_set_header HOST $host;proxy_set_header X-Real-IP $remote_addr;proxy_set_header X-Forwarded-FOR $proxy_add_x_forwarded_for;} error_page 404 / 404.html Location = / 404.html {root / usr/share/nginx/html;}} third: Nginx parses the error page of the php code
If the backend is parsed by php, you need to add a variable
Add a variable to the http section
Fastcgi_intercept_errors on will be fine.
Specify an error page:
Error_page 404 / 404.htmlscape location = / 404.html {root / usr/share/nginx/html;}
Specify an url address:
Error_page 404 / 404.htmltransfererrorship page 404 = http://www.test.com/error.html; thank you for reading, this is the content of "how to configure Nginx 404 page". After the study of this article, I believe you have a deeper understanding of how to configure Nginx 404 page, and the specific use needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.