Install & Use HAProxy in Linux Ubuntu 18

From Gejoreuy
Revision as of 09:13, 3 March 2020 by Gejor (talk | contribs)
Jump to navigation Jump to search

Introduction & concepts : https://www.digitalocean.com/community/tutorials/an-introduction-to-haproxy-and-load-balancing-concepts
Step by step installation and how to use : https://tecadmin.net/how-to-setup-haproxy-load-balancing-on-ubuntu-linuxmint/

Inj HAProxy configuration just change the listening below :

   listen stats *:1936
          stats enable
          stats hide-version
          stats refresh 30s
          stats show-node
          stats auth username:password
          stats uri  /stats

To :

  listen  stats
          bind     *:1936


Example with Multiple Backends Different Ports

frontend Local_Server1
    bind 10.0.0.7:81
    mode http
    default_backend My_Web_Servers1

frontend Local_Server2
    bind 10.0.0.7:82
    mode http
    default_backend My_Web_Servers2


backend My_Web_Servers1
    mode http
    balance roundrobin
    option forwardfor
    http-request set-header X-Forwarded-Port %[dst_port]
    http-request add-header X-Forwarded-Proto https if { ssl_fc }
    option httpchk HEAD / HTTP/1.1rnHost:localhost
    server komang-demotest-web1  10.0.0.9:80

backend My_Web_Servers2
    mode http
    balance roundrobin
    option forwardfor
    http-request set-header X-Forwarded-Port %[dst_port]
    http-request add-header X-Forwarded-Proto https if { ssl_fc }
    option httpchk HEAD / HTTP/1.1rnHost:localhost
    server komang-demotest-web2  10.0.0.10:80