Reputation: 465
So I am trying to protect sensitive information in Magento and I want 404
to be returned as HTTP status code instead of 403 for restricted pages so that potential threats are not aware that the directory they are accessing even exists.
location ^~ /supersecretdirectory/ {
return 404;
}
However what I get is the default Nginx 404. Is there a way to force Nginx use Magento's 404 page?
Upvotes: 0
Views: 249
Reputation: 465
By Defining CMS No Route Page in Magento admin you can internally rewrite nginx 404 to magento 404 by
# retun 404 for sensitive directory
location ^~ /supersecretdirectory/ {
return 404;
}
# route nginx 404 to Magento 404
error_page 404 /your-CMS-no-route.html;
location = /your-CMS-no-route.html {
root /path/to/root;
internal;
}
Upvotes: 1