HAProxy community

Load balancing UDP Traffic in HA Proxy

Hi Everyone,

I have simple load balancing scenario.

In my setup, I have HAProxy HA ( haproxy1, haproxy2 ) with a virtual IP ( and keepalived in both haproxy1, haproxy2.

I am sending the syslogs from a ESX host to the Virtual IP (, i am able to get the logs in haproxy1 and haproxy2 (checked via tcpdump) from haproxy1/haproxy2, the traffic is not getting forwarded to the backend servers (logstash1, logstash2), all the UDP or TCP ports are open.

I see in few of the posts or blogs about haproxy that the UDP is not supported in it, but to have it get supported, LVS has to be configured at the kernel level to load balance TCP or UDP traffic.

I tried multiple methods to configure LVS in Keepalived to have the traffic forwarded to the backend servers, but could not.

If anybody had encountered issue similar to this, then can you please shed some light into it or share some configs.

The following is the haproxy config and the keep alived configs.

haproxy config:

log /dev/log local0
log /dev/log local1 notice
chroot /var/lib/haproxy
stats socket /run/haproxy/admin.sock mode 660 level admin expose-fd listeners
stats timeout 30s
user haproxy
group haproxy

# Default SSL material locations
ca-base /etc/ssl/certs
crt-base /etc/ssl/private

# Default ciphers to use on SSL-enabled listening sockets.
# For more information, see ciphers(1SSL). This list is from:
#  https://hynek.me/articles/hardening-your-web-servers-ssl-ciphers/
# An alternative list with additional directives can be obtained from
#  https://mozilla.github.io/server-side-tls/ssl-config-generator/?server=haproxy
ssl-default-bind-options no-sslv3

# Fine-tuned configuration:
nbproc 4 # equal to number of cores
# default maxconn is 2000 (approx)
maxconn 100000
cpu-map 1 0
cpu-map 2 1
cpu-map 3 2
cpu-map 4 3

log global
mode http
#option httplog
mode tcp

option tcplog

    #option  syslog
option	dontlognull
    timeout connect 5000
    timeout client  50000
    timeout server  50000
    timeout http-keep-alive 10s
errorfile 400 /etc/haproxy/errors/400.http
errorfile 403 /etc/haproxy/errors/403.http
errorfile 408 /etc/haproxy/errors/408.http
errorfile 500 /etc/haproxy/errors/500.http
errorfile 502 /etc/haproxy/errors/502.http
errorfile 503 /etc/haproxy/errors/503.http
errorfile 504 /etc/haproxy/errors/504.http

frontend vip
stats enable
default_backend kibana_ui

backend kibana_ui
balance roundrobin
server prod-efk1.abc.com check
server prod-efk2.abc.com check backup

backend elasticsearch
balance roundrobin
server prod-es01.abc.com check
server prod-es02.abc.com check backup
server prod-es03.abc.com check backup

backend logstash
balance roundrobin
# mode tcp
server prod-fag01.abc.com check
server prod-fag02.abc.com check backup

listen stats
mode http
log global
stats enable
stats hide-version
stats realm LoadBalanced\ ELK\ Components
stats uri /haproxy?stats
stats auth haproxy:haproxy

    maxconn 10

    clitimeout      100s
    srvtimeout      100s
    contimeout      100s
    timeout queue   100s

    stats enable
    stats hide-version
    stats refresh 30s
    stats show-node
    stats uri  /

Keep alived config:

vrrp_script chk_haproxy {
#script “killall -0 haproxy”
#script “/usr/sbin/service haproxy status”
script “/usr/bin/pgrep haproxy”
interval 2
#weight 2

global_defs {
#router_id prod-haproxy01
#lvs_sync_daemon_interface eth0 VI_1

vrrp_instance VI_1 {
interface eth0
state MASTER
virtual_router_id 51
priority 110

unicast_peer {

virtual_ipaddress { # virtual ip address
track_script {

You don’t “get it supported by using LVS”. You are using LVS which is something enterely different than haproxy and does support UDP.

LVS and haproxy have nothing to do with each other. Please ask your question about LVS in the LVS community, for example the LVS mailing list.

Hello Lukastribus,

Thanks for your reply, i felt i have to use LVS along with HA Proxy/Keepalived to load balance UDP Traffic.

If i wanted to load balance UDP traffic through HA Proxy, then is it possible ?, if yes, then can you please share a sample configs ?

I don’t want to use LVS, my focus is only on HA Proxy and i need

Thanks & Regards,
Majid M A

No, haproxy does not support UDP.

Hi Lukastribus,
Many thanks for your reply.
I feel it supports TCP, if you share the sample haproxy for TCP, then it will be really great.

Thanks & Regards,
Majid M A

You are already have that configuration, you posted it yourself.

Doesn’t VMware use UDP/514 by default but have TCP/1514 as the alternate port? Have you considered using that alternate port so that you can continue to receive the logs via HAProxy. In reality, you can configure syslog/rsyslog/syslog-ng to send via UDP or TCP, it is just a change on the sending node. Depending on you logging solution, you also may want to send to a central syslog-ng server farm so you can filter, rewrite, and forward logs into your logging solution as you wish once centrally received.