Merge pull request #11 from bigbosst/defaults-and-naming
Defaults, Naming, and Multiple Binds
This commit is contained in:
commit
c351a70e00
2 changed files with 29 additions and 10 deletions
|
@ -33,6 +33,7 @@ defaults
|
|||
log {{ salt['pillar.get']('haproxy:defaults:log') }}
|
||||
mode {{ salt['pillar.get']('haproxy:defaults:mode') }}
|
||||
retries {{ salt['pillar.get']('haproxy:defaults:retries') }}
|
||||
balance {{ salt['pillar.get']('haproxy:defaults:balance', 'roundrobin') }}
|
||||
{%- if 'options' in salt['pillar.get']('haproxy:defaults', {}) %}
|
||||
{%- for option in salt['pillar.get']('haproxy:defaults:options') %}
|
||||
option {{ option }}
|
||||
|
@ -57,7 +58,7 @@ defaults
|
|||
#---------------------------------------------------------------------
|
||||
{%- if 'frontends' in salt['pillar.get']('haproxy', {}) %}
|
||||
{%- for frontend in salt['pillar.get']('haproxy:frontends', {}).iteritems() %}
|
||||
frontend {{ frontend[1].name }}
|
||||
frontend {{ frontend[1].get(name, frontend[0]) }}
|
||||
bind {{ frontend[1].bind }}
|
||||
{%- if 'redirects' in frontend[1] %}
|
||||
{%- for front_redirect in frontend[1].redirects %}
|
||||
|
@ -89,12 +90,14 @@ redirect {{ front_redirect }}
|
|||
#---------------------------------------------------------------------
|
||||
{%- if 'backends' in salt['pillar.get']('haproxy', {}) %}
|
||||
{%- for backend in salt['pillar.get']('haproxy:backends', {}).iteritems() %} # Backend loop start
|
||||
backend {{ backend[1].name }}
|
||||
backend {{ backend[1].get(name, backend[0]) }}
|
||||
{%- if 'redirects' in backend[1] %}
|
||||
{%- for redirect in backend[1].redirects %} # Redirect loop start
|
||||
redirect {{ redirect }}{% endfor %}
|
||||
{%- endif %}
|
||||
{%- if 'balance' in backend[1] %}
|
||||
balance {{ backend[1].balance }}
|
||||
{%- endif %}
|
||||
{%- if 'options' in backend[1] %}
|
||||
{%- for option in backend[1].options %}
|
||||
option {{ option }}
|
||||
|
@ -114,7 +117,7 @@ redirect {{ redirect }}{% endfor %}
|
|||
{%- endif %}
|
||||
{%- if 'servers' in backend[1] %}
|
||||
{%- for server in backend[1].servers.iteritems() %}
|
||||
server {{ server[1].name }} {{ server[1].host }}:{{ server[1].port }} {{ server[1].check }}{% endfor %}
|
||||
server {{ server[1].get(name,server[0]) }} {{ server[1].host }}:{{ server[1].port }} {{ server[1].check }}{% endfor %}
|
||||
{% endif %}
|
||||
{% endfor %} # Backend loop end
|
||||
{% endif %}
|
||||
|
|
|
@ -53,8 +53,7 @@ haproxy:
|
|||
- "X-Forwarded-Proto:\\ http"
|
||||
default_backend: www-backend
|
||||
|
||||
frontend2:
|
||||
name: www-https
|
||||
www-https:
|
||||
bind: "*:443 ssl crt /etc/ssl/private/certificate-chain-and-key-combined.pem"
|
||||
reqadd:
|
||||
- "X-Forwarded-Proto:\\ https"
|
||||
|
@ -63,7 +62,12 @@ haproxy:
|
|||
- url_static path_beg -i /static /images /javascript /stylesheets
|
||||
- url_static path_end -i .jpg .gif .png .css .js
|
||||
use_backends:
|
||||
- static if url_static
|
||||
- static-backend if url_static
|
||||
some-services:
|
||||
bind:
|
||||
- "*:8080"
|
||||
- "*:8088"
|
||||
default_backend: api-backend
|
||||
|
||||
backends:
|
||||
backend1:
|
||||
|
@ -76,8 +80,7 @@ haproxy:
|
|||
host: 192.168.1.213
|
||||
port: 80
|
||||
check: check
|
||||
backend2:
|
||||
name: static
|
||||
static-backend:
|
||||
balance: roundrobin
|
||||
redirect: scheme https if !{ ssl_fc }
|
||||
options:
|
||||
|
@ -92,8 +95,21 @@ haproxy:
|
|||
realm: LoadBalancer
|
||||
auth: "user:password"
|
||||
servers:
|
||||
server1:
|
||||
name: some-server
|
||||
some-server:
|
||||
host: 123.156.189.111
|
||||
port: 8080
|
||||
check: check
|
||||
api-backend:
|
||||
options:
|
||||
- http-server-close
|
||||
- forwardfor
|
||||
servers:
|
||||
apiserver1:
|
||||
host: apiserver1.example.com
|
||||
port: 80
|
||||
check: check
|
||||
server2:
|
||||
name: apiserver2
|
||||
host: apiserver2.example.com
|
||||
port: 80
|
||||
check: check
|
||||
|
|
Loading…
Reference in a new issue