Skip to content

Commit 52a4e1a

Browse files
committed
Merge pull request #52 from mmh/feature/allow_custom_options
allow custom options using "extra"
2 parents e465b79 + 822db0e commit 52a4e1a

3 files changed

Lines changed: 44 additions & 0 deletions

File tree

README.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ Currently, only a handful of options can be set using the pillar:
7474
+ port: the port to contact the server on
7575
+ check: set to check to enable checking
7676

77+
- For global, default, frontend, listener, backend and server it is possible to use the "extra" option for more rare settings not mentioned above.
7778

7879
``haproxy.service``
7980
-------------------

haproxy/templates/haproxy.jinja

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,15 @@ global
6363
{%- if 'ssl-default-bind-options' in salt['pillar.get']('haproxy:global', {}) %}
6464
{{- render_list_of_dictionaries('ssl-default-bind-options', salt['pillar.get']('haproxy:global:ssl-default-bind-options')) }}
6565
{%- endif %}
66+
{%- if 'extra' in salt['pillar.get']('haproxy:global', {}) %}
67+
{%- if salt['pillar.get']('haproxy:global:extra', {}) is string %}
68+
{{ salt['pillar.get']('haproxy:global:extra') }}
69+
{%- else %}
70+
{%- for line in salt['pillar.get']('haproxy:global:extra') %}
71+
{{ line }}
72+
{%- endfor %}
73+
{%- endif %}
74+
{%- endif %}
6675

6776
{%- for id, userlist in salt['pillar.get']('haproxy:userlists', {})|dictsort %}
6877
#------------------
@@ -125,6 +134,15 @@ defaults
125134
{%- if 'stats' in salt['pillar.get']('haproxy:defaults', {}) -%}
126135
{{ render_list_of_dictionaries('stats', salt['pillar.get']('haproxy:defaults:stats')) }}
127136
{%- endif %}
137+
{%- if 'extra' in salt['pillar.get']('haproxy:defaults', {}) %}
138+
{%- if salt['pillar.get']('haproxy:defaults:extra', {}) is string %}
139+
{{ salt['pillar.get']('haproxy:defaults:extra') }}
140+
{%- else %}
141+
{%- for line in salt['pillar.get']('haproxy:defaults:extra') %}
142+
{{ line }}
143+
{%- endfor %}
144+
{%- endif %}
145+
{%- endif %}
128146
{%- if 'errorfiles' in salt['pillar.get']('haproxy:defaults', {}) %}
129147
{%- for errorfile_name, errorfile in salt['pillar.get']('haproxy:defaults:errorfiles')|dictsort %}
130148
errorfile {{ errorfile_name }} {{ errorfile }}
@@ -316,6 +334,13 @@ listen {{ listener.get('name', listener_name) }}
316334
appsession {%- for option in listener.appsession %} {{ option }} {%- endfor %}
317335
{%- endif %}
318336
{%- endif %}
337+
{%- if 'extra' in listener %}
338+
{%- if listener.extra is string %}
339+
{{ listener.extra }}
340+
{%- else %}
341+
{%- for line in listerner.extra %} {{ line }} {%- endfor %}
342+
{%- endif %}
343+
{%- endif %}
319344
{%- if 'defaultserver' in listener %}
320345
default-server {%- for option, value in listener.defaultserver|dictsort %} {{ ' '.join((option, value|string, '')) }} {%- endfor %}
321346
{%- endif %}
@@ -402,6 +427,15 @@ frontend {{ frontend.get('name', frontend_name) }}
402427
{%- if 'stickons' in frontend %}
403428
{{- render_list_of_dictionaries('stickon', frontend.stickons) }}
404429
{%- endif %}
430+
{%- if 'extra' in frontend %}
431+
{%- if frontend.extra is string %}
432+
{{ frontend.extra }}
433+
{%- else %}
434+
{%- for line in frontend.extra %}
435+
{{ line }}
436+
{%- endfor %}
437+
{%- endif %}
438+
{%- endif %}
405439
{%- if 'default_backend' in frontend %}
406440
default_backend {{ frontend.default_backend }}
407441
{%- endif %}
@@ -513,6 +547,13 @@ backend {{ backend.get('name', backend_name) }}
513547
{%- if 'reqreps' in backend %}
514548
{{- render_list_of_dictionaries('reqrep', backend.reqreps) }}
515549
{%- endif %}
550+
{%- if 'extra' in backend %}
551+
{%- if backend.extra is string %}
552+
{{ backend.extra }}
553+
{%- else %}
554+
{%- for line in backend.extra %} {{ line }} {%- endfor %}
555+
{%- endif %}
556+
{%- endif %}
516557
{%- if 'defaultserver' in backend %}
517558
default-server {%- for option, value in backend.defaultserver|dictsort %} {{ ' '.join((option, value|string, '')) }} {%- endfor %}
518559
{%- endif %}

pillar.example

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,7 @@ haproxy:
127127
- url_static path_end -i .jpg .gif .png .css .js
128128
use_backends:
129129
- static-backend if url_static
130+
extra: "rspadd Strict-Transport-Security:\ max-age=15768000"
130131
some-services:
131132
bind:
132133
- "*:8080"
@@ -139,6 +140,7 @@ haproxy:
139140
balance: roundrobin
140141
redirects:
141142
- scheme https if !{ ssl_fc }
143+
extra: "reqidel ^X-Forwarded-For:"
142144
servers:
143145
server1:
144146
name: server1-its-name

0 commit comments

Comments
 (0)