Skip to content

Instantly share code, notes, and snippets.

@lsmith77
Created September 12, 2021 18:27
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 lsmith77/99502b98d8cabef79ad3c57bded5c108 to your computer and use it in GitHub Desktop.
Save lsmith77/99502b98d8cabef79ad3c57bded5c108 to your computer and use it in GitHub Desktop.
backend intercom1 {
.host = "13.248.193.164";
.port = "80";
.connect_timeout = 5s;
.first_byte_timeout = 5s;
.between_bytes_timeout = 5s;
}
backend intercom2 {
.host = "76.223.11.64";
.port = "80";
.connect_timeout = 5s;
.first_byte_timeout = 5s;
.between_bytes_timeout = 5s;
}
backend productboard1 {
.host = "3.214.110.180";
.port = "80";
.connect_timeout = 5s;
.first_byte_timeout = 5s;
.between_bytes_timeout = 5s;
}
backend productboard2 {
.host = "18.214.111.142";
.port = "80";
.connect_timeout = 5s;
.first_byte_timeout = 5s;
.between_bytes_timeout = 5s;
}
backend productboard3 {
.host = "52.3.24.77";
.port = "80";
.connect_timeout = 5s;
.first_byte_timeout = 5s;
.between_bytes_timeout = 5s;
}
sub vcl_init {
new intercom = directors.round_robin();
intercom.add_backend(intercom1);
intercom.add_backend(intercom2);
new productboard = directors.round_robin();
productboard.add_backend(productboard1);
productboard.add_backend(productboard2);
productboard.add_backend(productboard3);
}
sub vcl_recv {
if (req.http.host ~ "^diversifier-help") {
set req.backend_hint = intercom.backend();
set req.http.host = "diversifier-help.witty.works";
} elseif (req.http.host ~ "^diversifier-release-notes") {
set req.backend_hint = productboard.backend();
set req.http.host = "diversifier-release-notes.witty.works";
}
}
sub vcl_backend_response {
#Fix a strange problem: HTTP 301 redirects to the same page sometimes go in$
if (beresp.http.Location == "http://" + bereq.http.host + bereq.url
|| beresp.http.Location == "https://" + bereq.http.host + bereq.url
) {
if (bereq.retries > 2) {
unset beresp.http.Location;
#set beresp.http.X-Restarts = bereq.retries;
} else {
return (retry);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment