decoding base64 signed urls in varnish
Fronting imgproxy with varnish, to honor old url base64 signed urls the javascript file vcl 4.0; import blob; import digest; # Default backend definition. Set this to point to your content server. backend default { .host = "127.0.0.1"; .port = "8080"; } sub vcl_init { } sub vcl_recv { set req.http.base64part = regsub(req.url, "^/testpath/(.*)\.(.*)$", "\1"); set req.http.base64ashex = blob.transcode(encoding=HEX, decoding=BASE64URL, encoded=req.http.base64part); set req.http.imghash-hex = regsub(req.http.base64asHex, "^(.{0,64})(.*)$", "\1"); set req.http.imgauth-hex = regsub(req.http.base64asHex, "^(.{0,64})(.{0,32})(.*)$", "\2"); set req.http.imgparms-hex = regsub(req.http.base64asHex, "^(.{0,96})(.*)$", "\2"); set req.http.imgparms = blob.transcode(encoding=IDENTITY, decoding=HEX, encoded=req.http.imgparms-hex); set req.http.genimgauth = dige