-
Notifications
You must be signed in to change notification settings - Fork 1
/
load_balancer.conf
executable file
·58 lines (49 loc) · 1.55 KB
/
load_balancer.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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#
# Proxy / load balancer for public API.
#
# Hosts we will load balance between. Doesn't matter
# which ports you use, however remote servers in the
# pool should also be proxied to filter requests, to
# only allow connections from this load balancer for
# example.
upstream server_pool {
server localhost:port;
server 002.xxx.yyy.zzz;
server 003.xxx.yyy.zzz;
server 004.xxx.yyy.zzz:port;
server 005.xxx.yyy.zzz;
}
# Incoming requests will be served on port 80, but
# could be any unused port you like. Using port 80
# insures widespread access through most firewalls
# and makes for a cleaner connection string like:
# wss://baxters-sports.net/ws
server {
listen 80;
server_name _;
root /var/www/html/;
sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 65;
keepalive_requests 100000;
# Default location match - will drop all connections
# immediately without responding if websocket location
# below fails to match.
location / {
return 444;
}
# Matches websocket URL address
location ~ ^/ws$ {
limit_req zone=ws burst=5;
proxy_http_version 1.1;
proxy_connect_timeout 2;
proxy_pass http://server_pool;
proxy_set_header Host $host;
proxy_set_header Connection "upgrade";
proxy_set_header Upgrade $http_upgrade;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_next_upstream error timeout invalid_header http_500;
}
}