[Mongrel] Modifying Apache Conf To Block Leachers

Hunter Hillegas lists at lastonepicked.com
Thu Feb 22 13:28:46 EST 2007


I'm using Apache 2.2 + Mongrel with great success, using the sample  
configs from the Mongrel site.

We have some MP3s on the site and recently someone has been stealing  
them and basically leaching them from the site, linking to them from  
an off-site location.

I've been trying to modify my Apache conf to check the referrer and  
adjust accordingly as below but no luck. I'm wondering if someone  
else has any suggestions on getting this to work... I would expect  
this to send the user to error.html if the referrer is not the site  
in question but nothing at all happens...

Any suggestions appreciated, this stuff drives me batty.

URL: http://www.mysite.com/audio_file/the_audio_file/file.mp3

RewriteCond %{REQUEST_FILENAME} .*mp3$ [NC]
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !mysite\.com [NC]
RewriteCond %{HTTP_REFERER} !friendlysite\.com [NC]
RewriteCond %{HTTP_REFERER} !google\. [NC]
RewriteCond %{HTTP_REFERER} !search\?q=cache [NC]
RewriteRule (.*) /error.html

RewriteCond %{DOCUMENT_ROOT}/maintenance.html -f
RewriteCond %{SCRIPT_FILENAME} !maintenance.html
RewriteRule ^.*$ /maintenance.html [L]
# Rewrite index to check for static index.html
RewriteRule ^/$ /index.html [QSA]
# Rewrite to check for Rails cached pages with .html extensions
RewriteRule ^([^.]+)$ $1.html [QSA]
# All dynamic requests get sent to the cluster
RewriteRule ^/(.*)$ balancer://sitejive%{REQUEST_URI} [P,QSA,L]


More information about the Mongrel-users mailing list