forked from nicokaiser/nginx-websocket-proxy
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathload-balancing.conf
41 lines (32 loc) · 1.09 KB
/
load-balancing.conf
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
38
39
40
41
# WebSocket Proxy with Load Balancing
#
# Like the other examples, but there are three WS backends (ws1, ws2, ws3).
# Each client must always be forwarded to the same backend (e.g. when using
# HTTPS requests).
upstream myservice {
# Clients with the same IP are redirected to the same backend
ip_hash;
# Available backend servers
server ws1.example.com:8080;
server ws2.example.com:8080;
server ws3.example.com:8080;
}
server {
# see simple-wss.conf or simple-ws.conf
location /services/myservice {
# switch off logging
access_log off;
# redirect all HTTP traffic to localhost:8080
proxy_pass http://myservice;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
# WebSocket support (nginx 1.4)
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
# Path rewriting
rewrite /services/myservice/(.*) /$1 break;
proxy_redirect off;
}
}