Created
November 27, 2019 13:39
-
-
Save aondio/9d62661f75d74b9215cbf37508ec022c to your computer and use it in GitHub Desktop.
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
#/bin/bash | |
curl -I localhost:6081 -H "Cookie: client1" | |
curl -I localhost:6081 -H "Cookie: client2" | |
curl -I localhost:6081 -H "Cookie: client1" | |
curl -I localhost:6081 -H "Cookie: client4" | |
curl -I localhost:6081 -H "Cookie: client2" | |
curl -I localhost:6081 -H "Cookie: client1" | |
curl -I localhost:6081 -H "Cookie: client1" | |
curl -I localhost:6081 -H "Cookie: client2" | |
curl -I localhost:6081 -H "Cookie: client1" | |
curl -I localhost:6081 -H "Cookie: client4" | |
curl -I localhost:6081 -H "Cookie: client2" | |
curl -I localhost:6081 -H "Cookie: client1" |
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
vcl 4.1; | |
import cookieplus; | |
import header; | |
import std; | |
import directors; | |
backend default { | |
.host = "127.0.0.1"; | |
.port = "8081"; | |
} | |
backend s2 { | |
.host = "127.0.0.1"; | |
.port = "8082"; | |
} | |
sub vcl_init { | |
new cdir = directors.hash(); | |
cdir.add_backend(default,1); | |
cdir.add_backend(s2,1); | |
} | |
sub vcl_recv { | |
cookieplus.parse(req.http.cookie); | |
set req.backend_hint = cdir.backend(req.http.Cookie); | |
set req.http.x-backend = req.backend_hint; | |
#we return(pass) to prove it "sticks", run regular hash in a real setup instead | |
return (pass); | |
} | |
sub vcl_backend_response { | |
#PLACEHOLDER | |
# we add Set-Cookie handling is backends do not set them | |
} | |
sub vcl_deliver { | |
set resp.http.x-cookie = req.http.Cookie; | |
set resp.http.x-backend = req.http.x-backend; | |
# we now unset a bunch of resp headers to make the response easier to read | |
# do not do on real setups. | |
unset resp.http.Server; | |
unset resp.http.Date; | |
unset resp.http.Content-Type; | |
unset resp.http.Content-Length; | |
unset resp.http.X-Varnish; | |
unset resp.http.Age; | |
unset resp.http.Via; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment