HAPROXY

Posted on August 10, 2021
Tags: codeetc

1 PREREQ

wget https://github.com/PCRE2Project/pcre2/releases/download/pcre2-10.44/pcre2-10.44.tar.gz
tar -xzf pcre2-10.44.tar.gz
cd pcre2-10.44
./configure --enable-jit=auto
make
sudo make install
sudo apt install lua5.4
sudo apt install liblua5.4-dev
sudo apt-get install libssl-dev
make clean
make -j $(nproc) TARGET=linux-glibc USE_OPENSSL=1 USE_QUIC=1 USE_QUIC_OPENSSL_COMPAT=1 USE_LUA=1 USE_PCRE2_JIT=1 LUA_LIB_NAME=lua5.4
sudo make install

2 USAGE

haproxy
sudo nano /etc/haproxy/haproxy.cfg
# Simple configuration for an HTTP proxy listening on port 80 on all
# interfaces and forwarding requests to a single backend "servers" with a
# single server "server1" listening on 127.0.0.1:8000
global
    daemon
    maxconn 256

defaults
    mode http
    timeout connect 5000ms
    timeout client 50000ms
    timeout server 50000ms

frontend http-in
    bind *:80
    default_backend servers

backend servers
    server server1 127.0.0.1:8000 maxconn 32
python3 -m http.server 8000 --bind 127.0.0.1
sudo haproxy -f configuration.conf -c