Go to file
2024-09-29 21:34:44 +03:00
defaults Don't override haproxy.cfg if it is manageabled by haproxy data plane api 2024-09-29 21:34:44 +03:00
handlers haproxy: simplify versions tracking 2024-05-16 18:20:18 +03:00
meta initial commit 2023-02-08 01:36:25 +03:00
tasks Don't override haproxy.cfg if it is manageabled by haproxy data plane api 2024-09-29 21:34:44 +03:00
templates initial commit 2023-02-08 01:36:25 +03:00
vars haproxy: simplify versions tracking 2024-05-16 18:20:18 +03:00
.gitignore initial commit 2023-02-08 01:36:25 +03:00
README.md initial commit 2023-02-08 01:36:25 +03:00

Setup HAProxy service

Config example:

haproxy_ssl: yes
haproxy_self_sign_cert: yes
haproxy_config:
  frontend:
    well-known:
      bind: ':80'
      mode: http
      acl:
        - letsencrypt-acl path_beg /.well-known/acme-challenge/
        - has_cors res.hdr(Access-Control-Allow-Origin) -m found
      http-request:
        - redirect scheme https if !{ path_beg /.well-known/acme-challenge/ } !{ ssl_fc }
      use_backend:
        - letsencrypt-backend if letsencrypt-acl
    https:
      bind: ':443 ssl crt {{ haproxy_ssl_path }}'
      mode: http
      acl:
        - letsencrypt-acl path_beg /.well-known/acme-challenge/
      use_backend:
        - letsencrypt-backend if letsencrypt-acl
      default_backend: localhost_5001
  backend:
    letsencrypt-backend:
      mode: http
      server:
        - letsencrypt 127.0.0.1:8080
    localhost_5001:
      mode: http
      server:
        - localhost 127.0.0.1:5001
  listen:
    rabbitmq:
      bind: "10.89.10.112:5672"
      mode: tcp
      option:
        - tcpka
      server:
        - t1-dev-rabbitmq-1 10.89.10.71:5672 check inter 2000 rise 2 fall 5
        - t1-dev-rabbitmq-2 10.89.10.72:5672 check inter 2000 rise 2 fall 5
        - t1-dev-rabbitmq-3 10.89.10.73:5672 check inter 2000 rise 2 fall 5
    rabbitmq_management:
      bind: "10.89.10.112:15672"
      mode: http
      server:
        - t1-dev-rabbitmq-1 10.89.10.71:15672 check inter 2000 rise 2 fall 5
        - t1-dev-rabbitmq-2 10.89.10.72:15672 check inter 2000 rise 2 fall 5
        - t1-dev-rabbitmq-3 10.89.10.73:15672 check inter 2000 rise 2 fall 5
    stats:
      bind: ":9000"
      mode: http
      stats:
        - enable
        - hide-version
        - realm Haproxy\ Statistics
        - uri /haproxy_stats
        - auth {{ haproxy_stats_user }}:{{ haproxy_stats_password }}

Map example:

haproxy_map:
  hosts.map: |
    #domainname           backendname
    example.com backend
    *.example.com backend

Lua example:

haproxy_lua:
  invertPath.lua: |
    local function invertPath(host)
      host = host:gsub('website.*','')
      a, b = host:match"(.*)%.([^.]+)"
      -- print(a)
      -- print(b)
      s = b .. ":" .. a
      return s
    end
    
    core.register_converters("invertPath", invertPath)