I have the following anti-leeching rewrite rule in Apache, which i'd like to have in nginx. I see cookie or referrer rule examples. But none combining both, so I am not sure how to go about this.
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{HTTP_REFERER} !^$ [OR]
RewriteCond %{HTTP_REFERER} !^http(s)?://(www.)?domain\.com.*$ [NC]
RewriteCond %{HTTP_COOKIE} !^.*_.*$
RewriteRule \.(flv|jpg|jpeg|mp3|mpg|mp4|mov|wav|wmv|png|gif|swf|css|js|htc|woff|otf|eot|ttf)$ - [F,NS,L]
</IfModule>
It's a slightly relaxed rule which allows empty referrers if sent with a known cookie (_
for the example). But it will deny access without that cookie set when using invalid domain referrers.
0 Answers