Skip to content

Instantly share code, notes, and snippets.

@parsibox
Created September 2, 2025 11:32
Show Gist options
  • Save parsibox/2434d120a4d347ea63a23c8f99bc33b5 to your computer and use it in GitHub Desktop.
Save parsibox/2434d120a4d347ea63a23c8f99bc33b5 to your computer and use it in GitHub Desktop.
haproxy with config in haproxy.d folder
sudo tee /lib/systemd/system/haproxy.service >/dev/null <<'EOF'
[Unit]
Description=HAProxy Load Balancer
Documentation=man:haproxy(1)
Documentation=file:/usr/share/doc/haproxy/configuration.txt.gz
After=network-online.target rsyslog.service
Wants=network-online.target
[Service]
EnvironmentFile=-/etc/default/haproxy
EnvironmentFile=-/etc/sysconfig/haproxy
BindReadOnlyPaths=/dev/log:/var/lib/haproxy/dev/log
Environment="CONFIG=/etc/haproxy/haproxy.cfg" "CONFIG_DIR=/etc/haproxy/haproxy.d/" "PIDFILE=/run/haproxy.pid" "EXTRAOPTS=-S /run/haproxy-master.sock"
ExecStart=/usr/sbin/haproxy -Ws -f $CONFIG -f $CONFIG_DIR -p $PIDFILE $EXTRAOPTS
ExecReload=/usr/sbin/haproxy -Ws -f $CONFIG -c -q $EXTRAOPTS
ExecReload=/bin/kill -USR2 $MAINPID
KillMode=mixed
Restart=always
SuccessExitStatus=143
Type=notify
[Install]
WantedBy=multi-user.target
EOF
systemctl daemon-reload
systemctl restart haproxy
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment