Skip to content
KitploitKITPLOIT
ToolsExploitsBlog
Log in
Submit
ToolsExploitsBlog
Submit

Hacking, PenTest, and Cybersecurity Tools for Your Security Arsenal!

Kitploit is a directory of hacking, cybersecurity, and pentesting tools. Discover the latest project updates to find vulnerabilities, analyze systems, automate testing, and strengthen your security.

··Feeds·Contact·Privacy·© 2026 Kitploit

Tool Directory

Categories

View all categories
Loading categories
HAProxy-Keepalived-Sec-HighLoads — ✨ HAProxy ve Keepalived konusunu load balancer ve cluster'a ek olarak güvenlik(zayıf SSL/Kripto Kullanımı (LOGJAM) (CVE-2015-4000) zafiyeti önlemi) ve yüksek yüklere karşı ele alır. | Kitploit
Tools/GitHubGitHub/fatlan/haproxy-keepalived-sec-highloads
Vulnerability ScannersConfiguration AuditingNetwork Security
GitHubfatlan/haproxy-keepalived-sec-highloads

HAProxy-Keepalived-Sec-HighLoads

✨ HAProxy ve Keepalived konusunu load balancer ve cluster'a ek olarak güvenlik(zayıf SSL/Kripto Kullanımı (LOGJAM) (CVE-2015-4000) zafiyeti önlemi) ve yüksek yüklere karşı ele alır.

View Repository
62133 years agoNot yet reviewed

Most Popular

View all →

Discover the most used tools by our community.

Explore all tools

Browse our collection of tools

View all tools →
Share

HAProxy and Keepalived (LoadBalancer+Cluster+Sec+HighLoads) Installation and Configuration

Crepe

HAProxy is an open-source software that provides a proxy server service for TCP and HTTP based applications with high availability load balancing.

Keepalived is an open-source software capable of providing IP failover capability for more than two servers. Keepalived uses multicast communication technique among itself.

In our setup, we will use HAProxy for load balancing and Keepalived for IP failover, i.e., to make our HAProxy setup into a Cluster.

Our scenario consists of 3 servers. We will install HAProxy on these 3 servers and make them a load balancer. Then, by installing the Keepalived service, when one of the servers goes down, we will perform IP failover to switch to another server without interruption and keep our load balancer service running.

We will use 4 IP addresses (IPs are completely fictitious)

  1. Server 1 : 10.10.5.13
  2. Server 2 : 10.10.5.14
  3. Server 3 : 10.10.5.15
  4. Keepalived Virtual Ip : 10.10.5.5

Now let's install HAProxy and Keepalived services on all 3 servers as follows.

sudo add-apt-repository ppa:vbernat/haproxy-2.7 -y
sudo apt update
sudo apt install haproxy keepalived -y
sudo openssl dhparam -out /etc/haproxy/dhparams.pem 2048

Note1: The servers must have “net.ipv4.ip_nonlocal_bind=1”. Otherwise, the configuration to be used for HAProxy will give a bind error because it cannot host the same IP at the same time and the service will not work. You need to follow the steps below for this.

First, edit the file “vi /etc/sysctl.conf” and paste the following parameter, save and exit.

net.ipv4.ip_nonlocal_bind=1

Then run the following command.

sysctl -p

Note2: If you are going to use 443 SSL, you need to have the Bundle (.crt,.ca,*.key) of your SSLs named “haproxy.pem” in the “/etc/ssl/private/” directory.

Now let's look at the HAProxy configuration as an example below. You will use the same configuration for each HAProxy in your setup.

HAProxy

For this, you will edit the file “/etc/haproxy/haproxy.cfg”. The configuration below supports min HAv2.

vi /etc/haproxy/haproxy.cfg

The default values are also present below

global
        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
        daemon
#        maxconn 100000 #replaceable


        # 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-ciphers ECDH+AESGCM:DH+AESGCM:ECDH+AES256:DH+AES256:ECDH+AES128:DH+AES:RSA+AESGCM:RSA+AES:!aNULL:!MD5:!DSS
        #ssl-default-bind-options no-sslv3
	ssl-default-bind-ciphers ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384
	ssl-default-bind-options ssl-min-ver TLSv1.2 no-tls-tickets
	ssl-dh-param-file /etc/haproxy/dhparams.pem
	#tune.ssl.default-dh-param 2048


#	nbproc 1
#	nbthread 8

	tune.maxrewrite 16384
	tune.bufsize 32768

defaults
        log     global
        mode    http
        option  httplog
        option  dontlognull
	option forwardfor
#        maxconn 1000000 #replaceable
        timeout connect 3000000
        timeout client  6000000
        timeout server  6000000
        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

Dashboard configuration section for HAProxy (prometheus integration added for monitoring)

listen stats
        bind fatlan.com:8989
        mode http
        stats enable
        stats uri /stats
        option http-use-htx
        http-request use-service prometheus-exporter if { path /metrics }
        #stats hide-version
        stats realm HAProxy\ Statistics
        stats auth admin:admin

In the configuration below, ACL is used in two blocks. The first block will run the middleware-fatlan-backend block if the word “rest” appears anywhere in the link, the second block will run the backend fatlan-forum-backend for a different domain request (forum.fatlan.com), otherwise all requests will run in the fatlan-backend443 block. Except for other port redirects.

Redirecting port 80 to port 443 section

frontend fatlan80
        bind fatlan.com:80
        mode http
        redirect scheme https if !{ ssl_fc }

frontend fatlan443
        bind fatlan.com:443 ssl crt /etc/ssl/private/haproxy.pem ciphers ECDH+AESGCM:DH+AESGCM:ECDH+AES256:DH+AES256:ECDH+AES128:DH+AES:ECDH+3DES:DH+3DES:RSA+AESGCM:RSA+AES:RSA+3DES:!aNULL:!MD5:!DSS
        option httplog
	option forwardfor
 	#http-request set-header X-Client-IP req.hdr_ip([X-Forwarded-For])
        #option forwardfor except 127.0.0.0/8
        option http-server-close
	http-request set-header X-Forwarded-Proto https
#        reqadd X-Forwarded-Proto:\ https #old config
        mode http
        default_backend fatlan-backend443

ACL example configuration (proxypass) redirects if the word rest appears anywhere in the link

        acl middleware-fatlan path_beg /rest
        use_backend middleware-fatlan-backend if middleware-fatlan

ACL for different forum host redirect

    	acl host_fatlanforum hdr(host) -i forum.fatlan.com
    	use_backend fatlan-forum-backend if host_fatlanforum

Default redirection part, redirection part for 443

backend fatlan-backend443
        mode http
        balance roundrobin
        stick store-request src
        stick-table type ip size 256k expire 30m
        option forwardfor
#        option httplog
        option httpchk HEAD /
	
        server frontend_01 10.10.37.12:8001 check port 8001 inter 3000 rise 2 fall 3
        server frontend_02 10.10.37.13:8001 check port 8001 inter 3000 rise 2 fall 3

ACL incoming, rest redirection part

backend middleware-fatlan-backend
        mode http
        balance roundrobin
        stick store-request src
        stick-table type ip size 256k expire 30m
        option forwardfor
#        option httplog
        option httpchk OPTIONS /login HTTP/1.0
        http-check expect status 200
	http-request replace-path (.*)(?:rest\/)(.*) \1\2
#        reqrep ^([^\ :]*)\ /rest[/]?(.*) \1\ //\2  #old config 
	
        server middleware_01 10.10.37.34:3000 check port 4000 inter 12000 rise 3 fall 3
        server middleware_02 10.10.37.35:3000 check port 4000 inter 12000 rise 3 fall 3

ACL incoming, forum redirection part

backend fatlan-forum-backend
        mode http
        option forwardfor
#        option httplog
        option httpchk HEAD /
	
        server forum_01 10.10.37.45:8080 check port 8080 inter 3000 rise 2 fall 3

External examples can also be configured as follows.

Download Tool