Skip to content

Instantly share code, notes, and snippets.

@luishdez
Created January 2, 2014 03:10
Show Gist options
  • Save luishdez/8214477 to your computer and use it in GitHub Desktop.
Save luishdez/8214477 to your computer and use it in GitHub Desktop.
Varnish hotlinking protection
sub hot_link {
if (
(
req.http.host == "http://www.videoszoofilia.org" ||
req.http.host == "http://videoszoofilia.org") &&
req.url ~ "\.(js|css|jpg|jpeg|png|gif)$" &&
(req.http.referer &&
(req.http.referer !~ "^http://www.videoszoofilia.org/" && req.http.referer !~ "^http://videoszoofilia.org/"))
) {
error 403 "No more hot linking";
}
}
sub vcl_recv {
call hot_link;
...
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment