Created
September 19, 2016 13:26
-
-
Save gquintard/9579766cea9cde01352516d5cc1a855c 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
vcl 4.0; | |
import std | |
import directors | |
backend foo { | |
.host = "127.0.0.1"; | |
} | |
backend bar { | |
.host = "127.0.0.2"; | |
.port = "80"; | |
} | |
backend baz { | |
.host = "127.0.0.3"; | |
.port = "8080"; | |
} | |
sub vcl_init { | |
new rr = directors.rr(); | |
rr.add_backend(foo); | |
rr.add_backend(bar); | |
new fb = directors.fb(); | |
fb.add_backend(foo); | |
fb.add_backend(bar); | |
fb.add_backend(baz); | |
} | |
sub vcl_init { | |
if (req.url ~ ^/admin/) { | |
set req.backend_hint = "foo"; | |
} else if (req.url ~ \.html\$) { | |
set req.backend_hint = "rr"; | |
} else if (req.method == GET) { | |
set req.backend_hint = "foo"; | |
} else if (req.http.host ~ ^[^/\.]*\.example\.com) { | |
return (synth(404)); | |
} else if (req.url !~ ^/admin/) { | |
return (synth(404)); | |
} else if (req.url !~ \.html\$) { | |
return (synth(404)); | |
} else if (req.method != GET) { | |
set req.backend_hint = "fb"; | |
} else if (req.http.host !~ ^GET) { | |
set req.backend_hint = "bar"; | |
} | |
return(pass); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment