blob: 4b43c8e34898f183ced074b2131cf56dbfacd904 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
|
# relayd ~~ /etc/relayd.conf
# managed by Ansible
# ====== #
# tables
# ====== #
table <local> { 127.0.0.1 }
{% for h in groups["all"] %}
{% set h = dict(hostvars[h]) %}
{##}
{% if h.ip.in is defined %}
table <{{ h.ansible_host }}> { {{ h.ip.in }} }
{% endif %}
{##}
{% endfor %}
# ================ #
# filter for vhost
# ================ #
http protocol vhost {
{% for h in groups["all"] %}
{% set h = dict(hostvars[h]) %}
{##}
{% if h.ip.in is defined %}
pass request header "Host" value "{{ h.ansible_host }}.{{ _i.domain_name }}" forward to <{{ h.ansible_host }}>
{% endif %}
{##}
{% endfor %}
}
# ======================= #
# relays for all protocol
# ======================= #
{% set relays = {} %}
{% for h in groups["servers"] %}
{% set h = dict(hostvars[h]) %}
{##}
{% for service in h.services | sort(attribute="port") if service.domain is defined %}
{% set _ = relays.update({ service.port : [] }) if relays[service.port] is not defined %}
{% set key_changer = { "host" : h.ansible_host, "domain" : service.domain } %}
{% set _ = relays[service.port].append(key_changer) %}
{% endfor %}
{##}
{% endfor %}
{% for relay in relays %}
relay vhost_{{ relay }} {
listen on egress port {{ relay }}
protocol vhost
{% for h in relays[relay] %}
forward to <{{ h.host }}> port {{ relay }} check icmp
{% endfor %}
}
{% endfor %}
|