I am hosting several project sites on a machine running Apache. Of course I am using virtual hosts and they work as expected. However, currently accessing the bare IP of the machine yields the first virtual host alphabetically (as to be expected). I am having trouble with malicious actors randomly (probably iterating) to my machine's IP and spamming login pages or otherwise trying to cause trouble. I would like to serve nothing to anyone who attempts to connect to the machine's IP.
I have tried a virtual host named "000-nodomain.conf" that serves a directory with a blank index.html on port 80. However I would like to eliminate the directory and have the server just respond itself with nothing and not worry about reading from disk. In the most ideal case I would want the server to refuse requests entirely that don't have a domain name, though I'm not sure if that's possible.
As a side issue, without an SSL certificate for my IP (expensive!) anyone who attempts to access the bare IP over port 443 still get served a real site as it is the first virtual host that matches port 443. Is it possible to run a "normal" http virtual host on port 443? I don't care about the end user experience for anyone who connects via bare IP, but it cannot affect any other site being served.