-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhaproxy.cfg
74 lines (67 loc) · 2.42 KB
/
haproxy.cfg
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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
# Global settings for HAProxy instance
global
# Send logs to stdout for container logging
log stdout format raw local0
# Maximum concurrent connections
maxconn 4096
# Default settings applied to all sections unless overridden
defaults
log global
# Connection timeouts for safety
timeout connect 5s
timeout client 50s
timeout server 50s
# Combined frontend for both HTTP/RPC and WebSocket traffic
frontend combined_frontend
bind 0.0.0.0:8545
bind 0.0.0.0:8546
mode tcp
# Use a TCP mode ACL to detect WebSocket traffic (port 8546)
acl is_websocket dst_port 8546
# Route based on the destination port
use_backend ws_backend if is_websocket
default_backend rpc_backend
# Backend configuration for RPC nodes (port 8545)
backend rpc_backend
mode tcp
# Round robin load balancing between nodes
balance roundrobin
# Enable TCP health checks
option tcp-check
# Allow server retry on failure
option redispatch
# Sticky sessions configuration
stick-table type ip size 200k expire 30m
stick on src
# RPC nodes with health checks
server node1 35.89.200.123:8545 check inter 3s fall 2 rise 2
server node2 18.236.243.137:8545 check inter 3s fall 2 rise 2
server node3 54.212.168.35:8545 check inter 3s fall 2 rise 2
server node4 54.202.224.179:8545 check inter 3s fall 2 rise 2
# Backend configuration for WebSocket nodes (port 8546)
backend ws_backend
mode tcp
# Round robin load balancing between nodes
balance roundrobin
# Enable TCP health checks
option tcp-check
# Allow server retry on failure
option redispatch
# Sticky sessions configuration
stick-table type ip size 200k expire 30m
stick on src
# WebSocket nodes with health checks
server node1 35.89.200.123:8546 check inter 3s fall 2 rise 2
server node2 18.236.243.137:8546 check inter 3s fall 2 rise 2
server node3 54.212.168.35:8546 check inter 3s fall 2 rise 2
server node4 54.202.224.179:8546 check inter 3s fall 2 rise 2
# Health check endpoint for monitoring HAProxy status
# Only accessible from localhost for security
frontend health_check
# Bind only to localhost (127.0.0.1) to prevent external access
bind 127.0.0.1:8547
# Use HTTP mode since health checks are HTTP requests
mode http
# Create a simple health endpoint at /health
# Returns 200 OK if HAProxy is running
monitor-uri /health