blob: d1d667b9c62ddab6b5f5fb6707e8b1da71c5768a (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
|
#################################################################################################################################
# inspired by http://serverfault.com/questions/370890/best-way-to-deploy-my-node-js-app-on-a-varnish-nginx-server/371008#371008 #
#################################################################################################################################
# to use the signaling server behind a varnish cache server you need to define a backend for it
backend nodejs {
.host = "127.0.0.1";
#.host = "148.251.154.68";
.port = "4500";
}
# and also some modifications in vcl_recv
if (req.http.Upgrade ~ "(?i)websocket") {
set req.backend = nodejs;
return (pipe);
}
if (req.http.host == "chat.lookshe.org") {
if (req.url ~ "^/socket.io/") {
set req.backend = nodejs;
return (pipe);
}
}
# and at least vcl_pipe
sub vcl_pipe {
#Need to copy the upgrade for websockets to work
if (req.http.upgrade) {
set bereq.http.upgrade = req.http.upgrade;
}
set bereq.http.Connection = "close";
return (pipe);
}
|