I am trying to catch all traffic not caught by a sites-enabled configuration file, and instead of throwing the default 404, to instead throw a 200 with a blank response instead.
So, for example, if my site is https://www.example.com at ip x.x.x.x
and somebody maps https://www.bad.com to my ip at x.x.x.x
they would simply get a 200 with a blank content.
To accomplish this, I have a file located at /var/www/index.html
that is a blank file, and have the following rule set up in {nginxdir}/conf.d/200catchall.conf
which is imported in the standard {nginxdir}/nginx.conf file:
# Serve blank page to any requests not intended for one of our servers
server {
listen 443;
server_name _;
location / {
root /var/www
}
}
This works great for rendering the 200 blank screen for a request to https://www.bad.com. However, it tries to traverse the directory when something like https://www.bad.com/cgibin/nofile.php is requested, and ends up throwing an error to error.log and results ultimately in a 404.
I've also attempted to replace the root
directive with a try_files /var/www/index.html
directive, which seems to give the same result...
Have been pulling my hair out for a while on this - any advice?