by joering2 · 7y ago · 0 comments
To block those, you can feed their IP's to haproxy or iptables ipset.
fetch_google()
{
for line in $(dig +short txt _cloud-netblocks.googleusercontent.com | tr " " "\n" | grep include | cut -f 2 -d :)
do
dig +short txt "${line}"
done | tr " " "\n" | grep ip4 | cut -f 2 -d : | sort -n | uniq | xz -9ecv > _GOOGLE.netset.xz
};
In HAProxy, you could include the decompressed version of that IP list with something like acl BOTS src -f bot.txt
Then either redirect, reject, silent-drop.Google is going to crawl, you just can’t stop them from crawling even if you tell them not to in robots.txt. Best option at this point is to add a noindex tag on pages and let them crawl to see it.
An implied TOS notice on a separate page or footer is not considered enforceable last time I checked, likewise for robots.txt.