Skip to content

Commit

Permalink
Remove fragments from default (#3)
Browse files Browse the repository at this point in the history
* Remove fragments from default

* Update fragments.j2

* Update fragments.j2
  • Loading branch information
iMartyn authored and aleeriz committed Oct 23, 2017
1 parent caa5eb2 commit 82734db
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 24 deletions.
24 changes: 4 additions & 20 deletions defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
nginx_etc : "/etc/nginx"
nginx_default_root : "/usr/share/nginx/html" # Will only work for ubuntu
nginx_max_clients : 512
nginx_install_repo : "ubuntu" # Options: ["nginx", "ubuntu"]
nginx_install_repo : "ubuntu" # Options: ["nginx", "ubuntu"]
nginx_apt_state : "present" # Options: ["latest", "present"]

# Should we control sites enabled
Expand Down Expand Up @@ -31,27 +31,11 @@ nginx_site :
root: "{{ nginx_default_root }}"
}
## Use yaml
location2 :
location2 :
name : /doc/
type : location
alias : "/usr/share/doc/"
autoindex : "on"
autoindex : "on"
allow : "127.0.0.1"
deny : "all"
deny : "all"

fragments:
list:
- path: "~* ^/fragment1($|/.*$)"
proxy_pass: "some-upstream"
# If upstream not defined uses the target as a service name from consul
server: "upstream_address1"

- path: "~* ^/other_fragment($|/.*$)"
proxy_pass: "other-upstream"
server: "upstream_address2"

common_config:
# list of common nginx config options for all fragments
proxy_set_header:
- "X-Forwarded-Proto https"
- "Proxy ''" #https://httpoxy.org/
5 changes: 1 addition & 4 deletions templates/fragments.j2
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,10 @@
{% for fragment in fragments['list'] %}
location {{ fragment.path }} {
proxy_pass http://{{fragment.proxy_pass}};
{% if 'proxy_intercept_errors' in fragment %}
proxy_intercept_errors {{ fragment['proxy_intercept_errors'] }};
{% endif %}
{% set combined_config = fragments['common_config'] %}
{% set _ = combined_config.update(fragment) %}
{% for key, value in combined_config.iteritems() %}
{% if key in ['proxy_pass', 'path'] %}
{% if key in ['proxy_pass', 'path', 'server'] %}
{% else %}
{% if value is iterable and value is not string %}
{% for array_value in value %}
Expand Down

0 comments on commit 82734db

Please sign in to comment.