Directory restructuration
This commit is contained in:
parent
eb10288717
commit
b196905320
23 changed files with 127 additions and 166 deletions
68
templates/haproxy.cfg.j2
Normal file
68
templates/haproxy.cfg.j2
Normal file
|
|
@ -0,0 +1,68 @@
|
|||
defaults
|
||||
log global
|
||||
|
||||
timeout connect 3s
|
||||
timeout client 10s
|
||||
timeout server 10m
|
||||
{% if data["customerrors"] %}
|
||||
errorfile 400 /etc/haproxy/errors-custom/400.http
|
||||
errorfile 403 /etc/haproxy/errors-custom/403.http
|
||||
errorfile 408 /etc/haproxy/errors-custom/408.http
|
||||
errorfile 500 /etc/haproxy/errors-custom/500.http
|
||||
errorfile 502 /etc/haproxy/errors-custom/502.http
|
||||
errorfile 503 /etc/haproxy/errors-custom/503.http
|
||||
errorfile 504 /etc/haproxy/errors-custom/504.http
|
||||
{% endif %}
|
||||
|
||||
global
|
||||
log /dev/log local0
|
||||
maxconn 2000
|
||||
tune.ssl.default-dh-param 2048
|
||||
|
||||
{% if "stats" in data %}
|
||||
frontend stats
|
||||
bind *:{{ data["stats"]["port"] | default(1936) }}
|
||||
mode http
|
||||
stats enable
|
||||
stats hide-version
|
||||
stats realm Haproxy\ Statistics
|
||||
stats uri /
|
||||
stats auth {{ data["stats"]["username"] }}:{{ data["stats"]["password"] }}
|
||||
# acl is_proxystats hdr(host) -i some.host.com
|
||||
# default_backend srv_stats
|
||||
# use_backend srv_stats if is_proxystats
|
||||
default_backend srv_stats
|
||||
|
||||
backend srv_stats
|
||||
mode http
|
||||
server Local 127.0.0.1:{{ data["stats"]["port"] | default(1936) }}
|
||||
{% endif %}
|
||||
|
||||
{% for o in data["easymapping"] %}
|
||||
{% set salt = loop.index %}
|
||||
frontend http_in_{{ o["port"] }}_{{ salt }}
|
||||
bind *:{{ o["port"] }} {{ " ssl crt " + o["ssl_cert"] if "ssl_cert" in o else "" }}
|
||||
mode http
|
||||
|
||||
{% for k in o["redirect"] -%}
|
||||
redirect prefix {{ o["redirect"][k] }} code 301 if { hdr(host) -i {{ k }} }
|
||||
{% endfor -%}
|
||||
|
||||
{% for k in o["hosts"] %}
|
||||
{% set host = k.replace(".", "_") + "_{0}_{1}".format(o["port"], salt) %}
|
||||
acl is_rule_{{ host }}_1 hdr(host) -i {{ k }}
|
||||
acl is_rule_{{ host }}_2 hdr(host) -i {{ k }}:{{ o["port"] }}
|
||||
use_backend srv_{{ host }} if is_rule_{{ host }}_1 OR is_rule_{{ host }}_2
|
||||
{% endfor %}
|
||||
|
||||
{% for k in o["hosts"] %}
|
||||
{% set host = k.replace(".", "_") + "_{0}_{1}".format(o["port"], salt) %}
|
||||
backend srv_{{ host }}
|
||||
balance roundrobin
|
||||
mode http
|
||||
option forwardfor
|
||||
http-request set-header X-Forwarded-Port %[dst_port]
|
||||
http-request add-header X-Forwarded-Proto https if { ssl_fc }
|
||||
server srv {{ k }} check weight 1
|
||||
{% endfor %}
|
||||
{% endfor %}
|
||||
Loading…
Add table
Add a link
Reference in a new issue