Today suddenly found a problem, the site set up a custom 404 page, showing is no problem, just return the status code is 200, rather than 404!!
To see my nginx configuration:
Nginx.conf
The code is as follows
server {
...
Error_page 404 =/404.php;
...
}
At first glance there is nothing, the Internet search for a moment to know more than an equal sign!!! Instead of this:
Nginx.conf
The code is as follows
server {
...
Error_page 404/404.php;
...
}
Add other status code definition methods
Change nginx.conf joins in the HTTP definition area: fastcgi_intercept_errors on;
Set a 404 page for the specified location
The code is as follows
Location/my_blog {
Error_page 404 =/article_not_found.html;
}
You can use a single error page to work with multiple error codes
The code is as follows
Location/my_blog {
Error_page 502 503 504 =/server_error.html
}
Redirect to a completely different server, assuming you have an upstream server defined in the HTTP zone server2:
The code is as follows
Upstream Server2 {
Server 10.0.0.1:80;
}
server {
Location/my_blog {
Error_page 404 = @try_server2;
}
Location @try_server2 {
Proxy_pass Http://server2;
}
This feature can be used in the Nginx front-end +apache back-end server architecture.
Test configuration
/usr/local/nginx/sbin/nginx-t
Restart Nginx without error.
/etc/init.d/nginx restart