Skip to content

Commit 82734db

Browse files
iMartynaleeriz
authored andcommitted
Remove fragments from default (#3)
* Remove fragments from default * Update fragments.j2 * Update fragments.j2
1 parent caa5eb2 commit 82734db

File tree

2 files changed

+5
-24
lines changed

2 files changed

+5
-24
lines changed

defaults/main.yml

Lines changed: 4 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
nginx_etc : "/etc/nginx"
33
nginx_default_root : "/usr/share/nginx/html" # Will only work for ubuntu
44
nginx_max_clients : 512
5-
nginx_install_repo : "ubuntu" # Options: ["nginx", "ubuntu"]
5+
nginx_install_repo : "ubuntu" # Options: ["nginx", "ubuntu"]
66
nginx_apt_state : "present" # Options: ["latest", "present"]
77

88
# Should we control sites enabled
@@ -31,27 +31,11 @@ nginx_site :
3131
root: "{{ nginx_default_root }}"
3232
}
3333
## Use yaml
34-
location2 :
34+
location2 :
3535
name : /doc/
3636
type : location
3737
alias : "/usr/share/doc/"
38-
autoindex : "on"
38+
autoindex : "on"
3939
allow : "127.0.0.1"
40-
deny : "all"
40+
deny : "all"
4141

42-
fragments:
43-
list:
44-
- path: "~* ^/fragment1($|/.*$)"
45-
proxy_pass: "some-upstream"
46-
# If upstream not defined uses the target as a service name from consul
47-
server: "upstream_address1"
48-
49-
- path: "~* ^/other_fragment($|/.*$)"
50-
proxy_pass: "other-upstream"
51-
server: "upstream_address2"
52-
53-
common_config:
54-
# list of common nginx config options for all fragments
55-
proxy_set_header:
56-
- "X-Forwarded-Proto https"
57-
- "Proxy ''" #https://httpoxy.org/

templates/fragments.j2

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,10 @@
22
{% for fragment in fragments['list'] %}
33
location {{ fragment.path }} {
44
proxy_pass http://{{fragment.proxy_pass}};
5-
{% if 'proxy_intercept_errors' in fragment %}
6-
proxy_intercept_errors {{ fragment['proxy_intercept_errors'] }};
7-
{% endif %}
85
{% set combined_config = fragments['common_config'] %}
96
{% set _ = combined_config.update(fragment) %}
107
{% for key, value in combined_config.iteritems() %}
11-
{% if key in ['proxy_pass', 'path'] %}
8+
{% if key in ['proxy_pass', 'path', 'server'] %}
129
{% else %}
1310
{% if value is iterable and value is not string %}
1411
{% for array_value in value %}

0 commit comments

Comments
 (0)