mirror of
https://gitea.0xace.cc/ansible-galaxy/haproxy.git
synced 2024-11-24 16:06:40 +00:00
2.5 KiB
2.5 KiB
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)