I am running a VPS using Ubuntu from Rackspace cloud, and have access to IPTables and/or Ubuntu Uncomplicated Firewall (UFW), but need to block by referrer since I can't tell what the IPs requesting the image will be. I don't want to let the request get as far as Apache as that is already affecting performance. Is it possible to block with a firewall or is there a better way? Something like ...
-A INPUT -m string --string "Referrer: http://www.rockinrio.com.br" --algo bm --to 65535 -j DROP
... was recommended but I can't get it to work, but then normally I use UFW.