Skip to content

Instantly share code, notes, and snippets.

@gquintard
Created September 19, 2016 13:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gquintard/9579766cea9cde01352516d5cc1a855c to your computer and use it in GitHub Desktop.
Save gquintard/9579766cea9cde01352516d5cc1a855c to your computer and use it in GitHub Desktop.
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