As of 9/21/17, Snapt Balancer may not be used to create UDP load balancers as it is built on HAProxy. However, Snapt Accelerator is based on NGINX which has recently added support for UDP load balancing via upstream
groups.
A brief inspection of the NGINX configuration on a Snapt server also reveals that these stream groups are written to /etc/nginx/udp_upstreams
and /etc/nginx/udp_servers
.
To effectively "load balance" UDP services:
- Verify Snapt server is running at least NGINX version 1.9.13 (
/usr/sbin/nginx -v
) - Ensure Snapt Accelerator has been installed (Modules & Plugins -> Add Plugins -> Snaptins)
- Define upstreams for each UDP port (Accelerator -> UDP Upstreams)
- Add backend servers for each upstream (Accelerator -> UDP Upstreams -> Servers button of active upstream -> Add server tab)
- Define virtual IPs for each upstream (Accelerator -> UDP Servers -> Add Server tab)
Alternatively, these tasks may be done in bulk on the server via heredocs:
# Define upstreams with backend servers (UDP Upstreams)
cat <<EOF> /etc/nginx/udp_upstreams/service_53.conf
upstream service_53 {
server host01.example.com:53;
server host02.example.com:53;
server host03.example.com:53;
server host04.example.com:53;
}
EOF
cat <<EOF> /etc/nginx/udp_upstreams/service_137.conf
upstream service_137 {
server host01.example.com:137;
server host02.example.com:137;
server host03.example.com:137;
server host04.example.com:137;
}
EOF
# Define upstream virtual IPs (UDP Servers)
sudo cat<<EOF> /etc/nginx/udp_servers/service_53.conf
server {
listen 127.0.0.2:53 udp;
proxy_pass service_53;
}
EOF
sudo cat<<EOF> /etc/nginx/udp_servers/service_137.conf
server {
listen 127.0.0.2:137 udp;
proxy_pass service_137;
}
EOF
When finished, Reload Accelerator and verify virtual IP binding on the server:
netstat -ln
udp 0 0 127.0.0.2:53 0.0.0.0:*
udp 0 0 127.0.0.2:137 0.0.0.0:*