Spaces:
Running
Running
| # HAProxy setup script | |
| sudo apt-get update | |
| sudo apt-get install -y haproxy | |
| # Basic HAProxy config | |
| cat > /etc/haproxy/haproxy.cfg << 'EOF' | |
| 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 | |
| defaults | |
| log global | |
| mode http | |
| option httplog | |
| option dontlognull | |
| timeout connect 5000 | |
| timeout client 50000 | |
| timeout server 50000 | |
| frontend http_front | |
| bind *:80 | |
| default_backend http_back | |
| backend http_back | |
| balance roundrobin | |
| server server1 localhost:3000 check | |
| EOF | |
| sudo systemctl enable haproxy | |
| sudo systemctl start haproxy |