Skip to content

Instantly share code, notes, and snippets.

@bsphere
Created January 19, 2013 14:36
Show Gist options
  • Save bsphere/4572994 to your computer and use it in GitHub Desktop.
Save bsphere/4572994 to your computer and use it in GitHub Desktop.
backend nginx {
.host = "127.0.0.1";
.port = "8080";
}
backend node1 {
.host = "127.0.0.1";
.port = "3000";
}
backend node2 {
.host = "127.0.0.1";
.port = "3001";
}
sub vcl_recv {
if (req.http.Upgrade ~ "(?i)websocket") {
if (req.http.host ~ "domain1.com") {
set req.backend = node1;
} else if (req.http.host ~ "domain2.com") {
set req.backend = node2;
}
return(pipe);
} else {
set req.backend = nginx;
}
}
sub vcl_pipe {
if (req.http.upgrade) {
set bereq.http.upgrade = req.http.upgrade;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment