SepehrImanian
terraform-provider-haproxy
Go

Terraform HAProxy Provider

Last updated Jun 26, 2026
43
Stars
4
Forks
1
Issues
0
Stars/day
Attention Score
44
Language breakdown
Go 99.0%
Makefile 0.6%
Go Template 0.4%
Dockerfile 0.1%
Files click to expand
README

minio-provider-terraform

Terraform Provider for HAProxy

GitHub go.mod Go version GitHub Workflow Status GitHub release (latest by date including pre-releases)

Explore the docs »

⚠️ Disclaimer: This project is under Active Development and is not ready for production use. Please use at your own risk.

Table Of Contents

- About This Project - Data Plane API Installation - Usage - Examples - Building and Installing - License

About This Project

A Terraform provider to manage HAProxy. It use HAProxy Data Plane API to manage HAProxy.

Data Plane API Installation

To use this provider, you need to install HAProxy Data Plane API on your HAProxy server. or use entrprise version of HAProxy.

Usage

See our examples folder. For more information, see the documentation.

terraform {
  required_providers {
    haproxy = {
      source  = "SepehrImanian/haproxy"
      version = "0.0.9"
    }
  }
}

provider "haproxy" { url = "http://haproxy.example.com:8080" username = "username" password = "password" }

Examples

Manage all HAProxy with a single provider:

resource "haproxy_global" "global" {
  user          = "haproxy"
  group         = "haproxy"
  chroot        = "/var/lib/haproxy"
  daemon        = true
  master_worker = true
  maxconn       = 2000
  pidfile       = "/var/run/haproxy.pid"
  ulimit_n      = 2000
  crt_base      = "/etc/ssl/certs"
  ca_base       = "/etc/ssl/private"
  stats_maxconn = 100
  stats_timeout = 60
}

resource "haproxydefaults" "defaulttest" { name = "default_test" mode = "http" backlog = 10000 httplog = true httpslog = true tcplog = false retries = 3 check_timeout = 10 client_timeout = 10 connect_timeout = 10 httpkeepalive_timeout = 10 httprequesttimeout = 10 queue_timeout = 10 server_timeout = 9 serverfintimeout = 10 maxconn = 2000 }

resource "haproxyacl" "acltest" { name = "acl_test" index = 0 parentname = "backendtest" parent_type = "backend" criterion = "hdr_dom(host)" value = "example.com" dependson = [haproxybackend.backend_test] }

resource "haproxyfrontend" "fronttest" { name = "front_test" backend = "backend_test" httpconnectionmode = "http-keep-alive" acceptinvalidhttp_request = true maxconn = 100 mode = "http" backlog = 1000 httpkeepalive_timeout = 10 httprequesttimeout = 10 httpuseproxy_header = true httplog = true httpslog = true tcplog = false

compression { algorithms = ["gzip", "identity"] offload = true types = ["text/html", "text/plain", "text/css", "application/javascript"] }

forwardfor { enabled = true header = "X-Forwarded-For" ifnone = true }

dependson = [haproxybackend.backend_test] }

resource "haproxybind" "bindtest" { name = "bind_test" port = 8080 address = "0.0.0.0" parentname = "fronttest" parent_type = "frontend" maxconn = 3000 dependson = [haproxyfrontend.front_test] }

resource "haproxybind" "bindssl_test" { name = "bindssltest" port = 443 address = "0.0.0.0" parentname = "fronttest" parent_type = "frontend" ssl = true ssl_certificate = "/etc/haproxy/certs/example.com.pem" verify = "none" dependson = [haproxyfrontend.front_test] }

resource "haproxybackend" "backendtest" { name = "backend_test" mode = "http" httpconnectionmode = "http-keep-alive" server_timeout = 9 check_timeout = 10 connect_timeout = 10 queue_timeout = 10 check_cache = true

balance { algorithm = "roundrobin" }

httpchk_params { uri = "/health" version = "HTTP/1.1" method = "GET" }

forwardfor { enabled = true } }

resource "haproxyserver" "servertest" { name = "server_test" port = 8080 address = "172.16.13.15" parentname = "backendtest" parent_type = "backend" send_proxy = true check = true inter = 3 rise = 3 fall = 3 dependson = [haproxybackend.backend_test] }

resource "haproxyserver" "serverssl_test" { name = "serverssltest" port = 443 address = "172.16.13.16" parentname = "backendtest" parent_type = "backend" ssl = true check = true check_ssl = true verify = "none" dependson = [haproxybackend.backend_test] }

Building and Installing

Prebuilt versions of this provider are available on the releases page.

But if you need to build it yourself, changes vars in Makefile then:

git clone https://github.com/SepehrImanian/terraform-provider-haproxy.git
cd terraform-provider-haproxy
make build

License

Distributed under the Apache License. See LICENSE for more information.

Made with using Go.

🔗 More in this category

© 2026 GitRepoTrend · SepehrImanian/terraform-provider-haproxy · Updated daily from GitHub