My public website is getting a lot of get requests to endpoints like "wp-login.php", ".env", ".git/HEAD" and many others. This seems to be a non-trivial portion of my website's traffic and I'd like to discourage it or at least reduce its impact.
Option 1.
I've heard of tactics such as redirecting such requests to random 10 hour long youtube videos, like so: https://twitter.com/nick_craver/status/720062942960623616 Is this effective against a significant portion of these actors?
Option 2.
I could block ips that make requests to such endpoints by using something like this:
var http = require('http');
http.createServer(function (req, res)
{
var ip = req.ip || req.connection.remoteAddress || req.socket.remoteAddress || req.connection.socket.remoteAddress;
if (ip == '127.0.0.1') // exit if it's a particular ip
res.end();
}
or something like this: https://www.npmjs.com/package/express-ipfilter (though this seems to require a redeployment to add new ips to)
Option 3.
My current plan is not especially elegant, but the idea is to just never respond to a request to any of the known get requests I'm receiving, not sending them a redirect to youtube:
const bannedGetRequests = ["latest/dynamic/instance-identity/document","wp-login.php" ...]; <-about 1,500 that I've got in my logs now.
bannedGetRequests.forEach(request => {
app.get(request, function (req, res) {
return; //I'm not calling res.end() here on purpose, I'm hoping this will leave their connection open awaiting a response I'm never going to send, if this slows them down even a few milliseconds, it seems worthwhile to me.
});
});
Option 4.
Pay cloudflare. Their free tier does not seem to support bot suppression. Maybe it's not as big a deal as I think it is. I don't really want to go through what looks like a huge amount of work to setup some kind of support from Cloudflare only to find out it doesn't even address my concern. Furthermore, this is a web application, I don't really think that using a CDN is going to be especially helpful to me. I don't have very many users (aside from these bots I guess).
Is there anything I'm missing? Are any of these options objectively superior/inferior to others?
Additional information: This is running on an AWS elastic beanstalk which puts an Nginx server (from AWS) in front of it that I'm not sure I have any control over.