This is an old revision of the document!


Table of Contents

HAProxy

Installation

  • update the repository:
    sudo apt update && sudo apt upgrade -y
  • Install HAProxy:
    sudo apt install haproxy -y
  • Check the installed version:
    haproxy -v
  • Start and enable the service:
    sudo systemctl start haproxy
    sudo systemctl enable haproxy
  • Replace the contents of your /etc/haproxy/haproxy.cfg file with this HAProxy Configuration configuration.
  • Add Whitelist and Blacklist files.
  • Check the configuration file:
    sudo haproxy -c -f /etc/haproxy/haproxy.cfg
  • Restart the proxy:
    sudo systemctl restart haproxy
  • If you want to include your current external IP address to the whitelist file automatically, add a line to the end of Whitelist and add the following task to root's crontab file, calling it every 5 minutes:
    */5 * * * * head -n -1 /etc/haproxy/whitelist.lst > /etc/haproxy/whitelist.tmp && dig +short host.mydyndns.org >> /etc/haproxy/whitelist.tmp && mv /etc/haproxy/whitelist.tmp /etc/haproxy/whitelist.lst && systemctl reload haproxy

Settings

  • Crontab:
    15 3,15 * * * certbot renew --post-hook "systemctl reload haproxy" > /dev/null 2>&1
  • Get IP address:
    dig domain.name +short