Refactor: tried to refactor code
- move scripts to assets/scripts (and updated build) - put most logic into HaproxyConfigGenerator - created DockerLabelHandler for all label handling from previous code - added unit tests and fixtures to cover HaproxyConfigGenerator and DockerLabelHandler - added a Makefile with build (for docker build) and test targets
This commit is contained in:
parent
5f9eac4b8a
commit
08de132450
21 changed files with 387 additions and 131 deletions
11
templates/frontend-mode-http.j2
Normal file
11
templates/frontend-mode-http.j2
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
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 %}
|
||||
Loading…
Add table
Add a link
Reference in a new issue