Skip to content

Instantly share code, notes, and snippets.

@kriswallsmith
Created February 27, 2014 21:42
Show Gist options
  • Save kriswallsmith/9260178 to your computer and use it in GitHub Desktop.
Save kriswallsmith/9260178 to your computer and use it in GitHub Desktop.
Here's a decent Chef workaround for Varnish's lack of support for ACL behind a proxy.
sub vcl_recv {
if (req.url ~ "(?i)^/admin" && req.http.x-forwarded-for !~ "\b(<%= @ips.map{ |ip| Regexp.escape(ip) }.join('|') %>)$") {
error 750 "Moved Temporarily";
}
}
sub vcl_error {
if (obj.status == 750) {
set obj.http.Location = "/";
set obj.status = 302;
return(deliver);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment