Skip to content

Instantly share code, notes, and snippets.

@rezan
Created Mar 30, 2021
Embed
What would you like to do?
VHA6 req.url rewrite hook
#
# VHA6 req.url rewrite hook
#
# File location: /etc/varnish/vha6/hooks/states.vcl
#
import std;
sub vha6_hook_init {
}
sub vha6_hook_broadcast {
vha.log("HOOK BROADCAST SWAP");
# Swap out the hash for the url
http.req_set_url(9,
vha6_opts.get("broadcaster_scheme", "http") + "://" +
vha6_opts.get("broadcaster_host", "localhost") + ":" +
vha6_opts.get("broadcaster_port", "8088") +
bereq.url);
http.req_set_header(9, "vha6-hash", blob.encode(HEX, LOWER, bereq.hash));
}
sub vha6_hook_peer_recv {
vha.log("HOOK PEER RECV SWAP");
# Swap back in the hash
if (!req.http.vha6-hash) {
return (synth(500, "HASH SWAP FAIL"));
}
set req.url = "/" + req.http.vha6-hash;
}
sub vha6_hook_peer_fetch {
}
sub vha6_hook_origin_recv {
}
sub vha6_hook_origin_deliver {
}
sub vha6_hook_peer_insert {
}
# EOF
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment