Skip to content

Commit 606e661

Browse files
committed
allow given domain to be regex
1 parent e87eec9 commit 606e661

File tree

3 files changed

+12
-7
lines changed

3 files changed

+12
-7
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
*.swp

README.md

+7-7
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,13 @@ Information about the expected role parameters.
2828
### haproxy_applications
2929
The `haproxy_applications` parameter is a list of hashes defining the applications to load balance. Each item in the list may contain the following parameters.
3030

31-
32-
| parameter | required | default | choices | comments
33-
| --------------------- |:--------:|:-------:| --------------- |:--------
34-
| name | yes | | | Name of the application. Used in defining frontend and backend servers. Should be descriptive as will show up in HAProxy stats. Must match `/a-zA-Z0-9-_/`
35-
| domain | yes | | | FQDN which will resolve to the HAProxy server(s) to then load balance the `servers`
36-
| http_redirect | no | `false` | `true`, `false` | `true` to automatically redirect http to https, `false` not to redirect.
37-
| servers | yes | | | List of hashes defining servers to load balance.
31+
| parameter | required | default | choices | comments
32+
| --------------------- |:--------:|:-------:| ----------- |:--------
33+
| name | yes | | | Name of the application. Used in defining frontend and backend servers. Should be descriptive as will show up in HAProxy stats. Must match `/a-zA-Z0-9-_/`
34+
| domain | yes | | | FQDN which will resolve to the HAProxy server(s) to then load balance the `servers`. Can either just be a simple FQDN or a regex statement to match a domain.
35+
| domain\_is\_regex | no | false | true, false | `true` if the given `domain` is regex, `false` to treat as plane FQDN.
36+
| http\_redirect | no | false | true, false | `true` to automatically redirect http to https, `false` not to redirect.
37+
| servers | yes | | | List of hashes defining servers to load balance.
3838

3939
#### servers
4040
Each element in the `haproxy_applications` list must contain a `servers` key which is a list of hashes defining the servers to load balance for the respective application. Each item in the list may contain the following parameters.

templates/be_tcp.map.j2

+4
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
11
{% for application in haproxy_applications %}
2+
{% if application.domain_is_regex | default(false) %}
3+
^{{ application.domain }}(:[0-9]+)?(/.*)?$ {{application.name}}
4+
{% else %}
25
^{{ application.domain | regex_escape() }}(:[0-9]+)?(/.*)?$ {{application.name}}
6+
{% endif %}
37
{% endfor %}

0 commit comments

Comments
 (0)