Skip to content

Varnish and Socket.IO

visionmedia edited this page Nov 17, 2011 · 1 revision

To utilize WebSockets with Varnish crack open your VCL (/etc/varnish/default.vcl in my case), and add the following. This will put Varnish into pipe mode on Upgrade, subsequent data will be piped to the backend.

sub vcl_pipe {
  if (req.http.upgrade) {
    set bereq.http.upgrade = req.http.upgrade;
  }
}

sub vcl_recv {
  if (req.http.Upgrade ~ "(?i)websocket") {
    return (pipe);
  }
}
Clone this wiki locally