Created
August 23, 2016 02:50
-
-
Save drakemccabe/7e4ce3281b9d4688c60f408e0260e256 to your computer and use it in GitHub Desktop.
common varnish vcl functions
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# call fucntion in vcl_res | |
# Throw error on spam bot comment attempt | |
# if first letter of comment ID is not numeric, throw 404. | |
sub clean_comment { | |
if (req.url ~ "comment\/reply\/\d*\/\D") { | |
error 404 "Page Not Found"; | |
} | |
} | |
# normalize url | |
sub normalize_req_url { | |
if (req.url ~ "^/(?:\?.*)?$") { | |
set req.url = "/"; | |
} | |
if (req.url ~ "(\?|&)(campname|camplink|utm_[a-z]+)") { | |
set req.url = regsuball(req.url, "(campname|camplink|utm_[a-z]+)=[%\._A-z0-9-]+&?", ""); | |
} | |
set req.url = regsub(req.url, "(\?&|\?|&)$", ""); | |
} | |
## block specific hostname | |
if ( req.http.host ~ "(hostname\.com)$" ) { | |
error 403 "Access denied"; | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment