Last active
September 22, 2017 09:12
-
-
Save Integralist/835e6ce181584bec9ba6391d29ebaf12 to your computer and use it in GitHub Desktop.
[Varnish VCL] use vcl to store provided query string and path into HTTP response headers #tags: vcl, varnish
This file contains hidden or 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
vcl 4.0; | |
backend default { | |
.host = "www.vclfiddle.net"; | |
.port = "80"; | |
} | |
sub vcl_recv { | |
if (req.url ~ "(foo/bar)") { | |
set req.http.X-QS = regsub(req.url, "^[^?]+\?", ""); // good=hey&bad1=true&bad2=boop | |
set req.http.X-Path = regsub(req.url, "\?.+$", ""); // /foo/bar | |
} | |
} | |
/* | |
curl http://www.vclfiddle.net/foo/bar?good=hey&bad1=true&bad2=boop --header 'User-Agent: vclFiddle' | |
http://vclfiddle.net/161102-3c995c5/44 | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment