Ask HN: Best way to block an EC2-hosted scraper?
Windy Citizen gets slooooow about once every hour and according to our logs, around this same time, someone or something is making a ton of requests to our RSS feeds, grabbing hundreds of them at once.
From what I can tell, the thing grabbing this stuff is hosted on Amazon EC2. I've tried blocking the IP address before but it seems to refresh and then the problem comes back. How do I shut this idiot down?
The feed URLs being grabbed are all have the following URL format: /neighborhood//feed
These are old URLs from a prior schema we had. They're not even valid anymore. I think this is part of the problem. Basically this scraper is causing a ton of 404s every 30 minutes.
Is there a way to just block out anything trying to hit URLs that match a regex for that URL structure? Something else?
Update: I've added this to my nginx.conf file:
location ~ /neighborhoods/[-\w]+/feed/?$ { deny all; }
And it appears to be working. It's successfully sending a 403 when people request those URLs.
Now, anyone have suggestions for fun things I can redirect the scraper to?
(Note: all these rules are for default deny with a rule like "-A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT" to ignore established states. If your firewall setup is different, then the rules will need to be modified.)
There is also a program called fail2ban that will read logs and apply temporary bans based on what the logs say.
My solution to this problem is to just cache agressively. Hundreds of requests per second is nothing for Varnish.
denyhosts and fail2ban are better ideas for dropping bad actors on the net.
So this is not something I worry about. ssh password crackers and script kiddies taking down my website are a little more worrisome.
http://aws-portal.amazon.com/gp/aws/html-forms-controller/co...
You can use technical countermeasures to defend your site, but you'd be doing the rest of the Internet a favor to get them knocked off Amazon.
Also, block generic user-agents on rss feeds. Most everyone was able to change theirs for delicious, and we did an insane amount of rss traffic.
Only thing is you need to append keys randomly, say one out of 5 requests, in different locations if possible. And you should hand out 20 or so different unique strings.
Then use google alerts to find them republishing your stuff an send DMCA takedown notices with Google (don't send them a c&d first so you have the element of surprise and maximum chance of causing real pain). If they don't take care of the DMCA issue with Google, Google will remove their pages from the index. They won't know why but their site will slowly die.
the other thing to do is include some some encoding of the served-to IP address (maybe md5 of the first and last half of the IP?)
(Talking about SHA1 because I used it myself in a lighter version - just a hash of my name - to check how the search engines work with the content of my little blog).
I don't care whether the unique strings collide (although I love the idea of being able to tie the IP address of the crawler to the page on which the content was published for maximum evidence collection), I just want Google Alerts to find them reliably AND I don't want the spammer to catch on and be able to easily remove the unique strings before I catch him.
The only way for him to find my little landmines (to strip them) would be to read through every piece of content he scraped from me.
This way you will want that they steal more from you :-)
(how to put these backlinks in a way that would be difficult to remove - is another story. But if you use other links, e.g. tinyurl, in your material - then you could probably use that :-) Still fairly simple to remove but would require more work from them.)
http://www.varnish-cache.org/
And if they have a really obvious user-agent you could block that using Varnish: http://omninoggin.com/web-development/block-unwanted-spam-bo...
And if you're not afraid of using Varnish's VCL InlineC stuff, then you could add rate limiting to Varnish: http://drcarter.info/2010/04/how-fighting-against-scraping-u...
Basically... Varnish has become my Swiss army tool for rejecting crap traffic (and caching good traffic obviously).
https://forums.aws.amazon.com/ann.jspa?annID=877
It's interesting to see the size of their deployments measured in usable IP space.
Varnish serves 404s quickly and happily, and will keep the storm from even reaching your apaches. You won't even notice it when the scrapers come in.
We are try to provide valuable service to people and would want to know that we are causing problems. We have implemented the ability to work with robots.txt files.
If the nodes are not from a legitimate service then they will be shutdown.
If you can figure out who's actually running it (does the user agent say?), simply sending them an email and asking them to throttle their script may be the simplest solution.
http://aws-portal.amazon.com/gp/aws/html-forms-controller/co...
In my experience they take it seriously and deal with it promptly.
I found it a little tricky to set up (the core rules it ships with by default are way too aggressive, IMHO), but it does exactly what you're asking: block requests by regex.
I just added some lines to my nginx.conf though that appear to be working based on tips from here and elsewhere:
location ~* /neighborhoods/[-\w]+/feed/?$ { deny all; }