Files
NodeBB/docs/configuring/proxies/varnish.rst

37 lines
933 B
ReStructuredText
Raw Normal View History

2014-04-25 18:07:18 -04:00
Configuring Varnish Cache
==========================
2014-04-25 17:43:41 -04:00
2014-04-25 18:07:18 -04:00
To be sure Varnish will work properly with NodeBB check that your configuration ``/etc/varnish/default.vcl`` is optimized for **websockets**.
2014-04-25 17:43:41 -04:00
2014-04-25 18:07:18 -04:00
.. code::
2014-04-25 17:43:41 -04:00
2014-04-25 18:07:18 -04:00
backend nodebb {
.host = "127.0.0.1"; # your nodebb host
.port = "4567"; # your nodebb port
2014-04-25 17:43:41 -04:00
}
2014-04-25 18:07:18 -04:00
sub vcl_recv {
# Pipe websocket connections directly to Node.js
if (req.http.Upgrade ~ "(?i)websocket") {
set req.backend = nodebb;
return (pipe);
2014-04-25 17:43:41 -04:00
}
2014-04-25 18:07:18 -04:00
# NodeBB
if (req.http.host == "forum.yourwebsite.com") { # change this to match your host
if (req.url ~ "^/socket.io/") {
set req.backend = nodebb;
return (pipe); # return pass seems not working for websockets
}
return (pass); # don't cache
}
2014-04-25 17:43:41 -04:00
}
2014-04-25 18:07:18 -04:00
sub vcl_pipe {
# Need to copy the upgrade header
if (req.http.upgrade) {
set bereq.http.upgrade = req.http.upgrade;
}
}