Automatically ban IP address if it accesses a certain URL

Solution 1:

Consider tarpitting these requests instead.

HAProxy (and I assume other HTTP proxies) has the ability to identify 'malicious' scan hits and delay the response (thus temporarily slowing the attack script).

Blocking the response entirely will just have the attack script move along to its next target immediately.

Solution 2:

You could, but that would make denial-of-service attacks trivial. All an attacker needs to do is access your site through the same proxy I'm using and hit one of those URLs and then I can't access your site. There are still entire cities that use a web proxy.