Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@linuxmalaysia
Last active May 12, 2019 23:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save linuxmalaysia/3a26cf3f7e2b2b2a0e1f009d8d0cea1a to your computer and use it in GitHub Desktop.
Save linuxmalaysia/3a26cf3f7e2b2b2a0e1f009d8d0cea1a to your computer and use it in GitHub Desktop.
haproxy.cfg Haproxy For Elastic beats And Logstash
# Haproxy For Elastic beats And Logstash
# Date: 13 May 2019
# 1) Example of haproxy.cfg listen for Filebeat or other beats by using port 5044/tcp
# And load balance to 2 servers.
# https://www.haproxy.com/blog/introduction-to-haproxy-logging/
# Please read above article for syslog configuration to listen port 514
# Or change config log to
# log /dev/log local0
global
log 127.0.0.1:514 local2
chroot /var/lib/haproxy
user haproxy
group haproxy
daemon
spread-checks 5
maxconn 50000
# turn on stats Unix socket
stats socket /var/lib/haproxy/stats
defaults
log global
mode tcp
timeout connect 5000ms
timeout client 5000ms
timeout server 5000ms
retries 3
listen stats # Define a listen section called "stats"
bind :9000 # Listen on localhost:9000
mode http
stats enable # Enable stats page
### stats hide-version # Hide HAProxy version
stats realm Haproxy\ Statistics # Title text for popup window
stats uri /haproxy_stats # Stats URI
stats auth username:password # Authentication credentials, change this.
frontend frontend
bind 0.0.0.0:5044
maxconn 40000
mode tcp
option tcplog
default_backend backend
backend backend
mode tcp
option log-health-checks
option redispatch
balance roundrobin
server upstream2 elk2:5044 check on-marked-down shutdown-sessions
server upstream3 elk3:5044 check on-marked-down shutdown-sessions
# define hostname in /etc/hosts or DNS
# Prepare by: Harisfazillah Jamel
# V1 13 May 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment