When disabling unbound domain name and IP direct access to nginx, I created the following server
server {
listen 80 default;
server_name _;
fastcgi_intercept_errors on;
error_page 404 /data/www/error_page/404.html;
return 404;
}
error_page content is as follows:
404 Not Found!
nginx -t test passed nginx -s reload reloaded successfully Why is the 404 page that comes with nginx still returned? I checked the manual and found out that this is how to set up the 404 page~
为情所困2017-05-16 17:31:04
The second parameter of error_page is URI, which is the path relative to the root directory of the site, not the physical path
According to your needs, it is recommended to change to:
root /data/www;
error_page 404 /error_page/404.html;
淡淡烟草味2017-05-16 17:31:04
Thank you Elite Prince, I re-read the description of error_page in nginx wiki. It does indicate that the context of 404 is uri. I reconfigured root for default and then specified the relative path of 404. But the problem arises when accessing an unbound domain name (such as cc.com) returns the 404 page that comes with nginx, and accessing cc.com/aaa.html returns a custom 404 page. It will take full effect if you additionally specify index to 404.html. In addition, using location to define / as an internal restriction can also return 404.