# relayd ~~ /etc/relayd.conf # managed by Ansible # ====== # # tables # ====== # table { 127.0.0.1 } {% for h in groups["servers"] %} {% 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 reverse_proxy { pass request header "Host" value "{{ global.domain_name }}" forward to {% for h in groups["servers"] %} {% set h = dict(hostvars[h]) %} {##} {% if h.ip.in is defined %} {% for service in h.services if service.domain is defined %} pass request header "Host" value "{{ service.domain }}.{{ global.domain_name }}" forward to <{{ h.ansible_host }}> {% endfor %} {% endif %} {##} {% endfor %} } # ======================= # # relays for all protocol # ======================= # relay www { listen on egress port 80 protocol reverse_proxy forward to port 80 check icmp {% for hostname in groups["servers"] %} {% set h = dict(hostvars[hostname]) %} {% for service in h.services if service.domain is defined %} forward to <{{ hostname }}> port {{ service.port }} check icmp {% endfor %} {% endfor %} }