HA Proxy Ansible Role https://www.haproxy.org/
Find a file
Repository files (latest commit first)
Filename Latest commit message Latest commit date
Conrad 6837592f0d
All checks were successful
Lint + Tag / format (push) Successful in 56s
Lint + Tag / tag (push) Successful in 1m13s
fix: updated pipeline + tni git
2026-10-12 16:43:59 +07:00
.forgejo/workflows fix: updated pipeline + tni git 2026-10-12 16:43:59 +07:00
defaults feat: proxy protocol is now optional 2026-09-03 02:46:30 +02:00
handlers feat: first running version 2026-04-24 12:20:12 +02:00
meta feat: first running version 2026-04-24 12:20:12 +02:00
tasks feat: proxy protocol is now optional 2026-09-03 02:46:30 +02:00
templates feat: proxy protocol is now optional 2026-09-03 02:46:30 +02:00
.gitignore feat: first running version 2026-04-24 12:20:12 +02:00
CHANGELOG.md fix: updated pipeline + tni git 2026-10-12 16:43:59 +07:00
LICENSE feat: first running version 2026-04-24 12:20:12 +02:00
README.md Prettified Code! 2026-09-03 00:46:43 +00:00

HAProxy

Installs and configures HAProxy as a layer-7 domain-based reverse proxy, routing HTTP and HTTPS traffic to backends by hostname.

Requirements

None.

Variables

Variable Default Description
ha_connections [] List of backend routing rules. Required (must be non-empty). See Connections below.
ha_uninstall false Stops, disables, and purges HAProxy.

Connections

Each entry in ha_connections defines one backend:

Key Required Description
urls Yes List of hostnames to route to this backend.
ip Yes Backend IPv4 address.
is_fallback No If true, this backend receives all traffic that matches no other rule. At most one entry may be true.
proxy_protocol No If false, don't send PROXY protocol v2 to this backend (default true). See Notes — only for backends with no PROXY protocol support.

Usage

Minimal setup:

ha_connections:
  - urls:
      - example.com
      - www.example.com
    ip: 1.2.3.4

With a fallback backend:

ha_connections:
  - urls:
      - app.example.com
    ip: 1.2.3.4
  - urls:
      - other.example.com
    ip: 5.6.7.8
    is_fallback: true

Uninstall

To stop, disable, and purge HAProxy:

ha_uninstall: true

Notes

  • Both HTTP (:80) and HTTPS (:443) frontends are configured. HTTPS routing uses TCP mode with SNI inspection — TLS is not terminated at HAProxy.
  • Backends use PROXY protocol v2 (send-proxy-v2) by default to forward the original client IP. Because HTTPS is TCP-passthrough (no TLS termination), this is the only way a backend learns the real client IP — there's no X-Forwarded-For fallback. The backend must explicitly trust and parse it (e.g. Traefik with entryPoints.*.proxyProtocol.trustedIPs set to this host's IP) or the connection will be silently dropped. Set proxy_protocol: false on a connection if its backend has no PROXY protocol support at all.
  • The generated config is validated with haproxy -c -f before being applied. HAProxy is reloaded gracefully on config change.