Skip to content

Commit

Permalink
Change nginx_extra_locations to accept a text block
Browse files Browse the repository at this point in the history
  • Loading branch information
nickjj committed Jun 2, 2014
1 parent 7df355f commit 8669148
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 26 deletions.
19 changes: 11 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,15 +65,18 @@ nginx_error_pages:
- { error_code: 502 503 504, error_page: 502.html }
# By default there are no extra locations but you can add as many as you want.
# You may use a string or regex for each location key.
# Don't forget the | to enable text blocks, feel free to use template tags too.
# The values must be valid nginx syntax, don't forget the semi-colons!
nginx_extra_locations:
# "/somewhere":
# - return;
# "/yay":
# - # directive 1 would go here;
# - # directive 2 would go here;
# - # ... add as many directives as you want;
nginx_extra_locations: |
# location / {
# return;
# }
#
# location ~ ^/(images|javascript|js|css|flash|media|static)/ {
# # directive 1 would go here;
# # directive 2 would go here;
# # ... add as many directives as you want;
# }
# If this is false then your ssl cert/key is not transferred and none of the
# ssl values are output to your nginx config.
Expand Down
17 changes: 10 additions & 7 deletions defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,16 @@ nginx_error_pages:
- { error_code: 500, error_page: 500.html }
- { error_code: 502 503 504, error_page: 502.html }

nginx_extra_locations:
# "/somewhere":
# - return;
# "/yay":
# - # directive 1 would go here;
# - # directive 2 would go here;
# - # ... add as many directives as you want;
nginx_extra_locations: |
# location / {
# return;
# }
#
# location ~ ^/(images|javascript|js|css|flash|media|static)/ {
# # directive 1 would go here;
# # directive 2 would go here;
# # ... add as many directives as you want;
# }

nginx_ssl: false
nginx_listen_ssl: 443
Expand Down
12 changes: 1 addition & 11 deletions templates/nginx_sites-available.conf.j2
Original file line number Diff line number Diff line change
Expand Up @@ -58,17 +58,7 @@ server {
try_files $uri @{{ nginx_backend_name }};
}

{% if nginx_extra_locations is iterable %}
{% for key, value in nginx_extra_locations.items() %}
location {{ key }} {
{% if value is iterable %}
{% for k in value %}
{{ k }}
{% endfor %}
{% endif %}
}
{% endfor %}
{% endif %}
{{ nginx_extra_locations|indent(2) }}

{% if nginx_assets_enabled %}
location {{ nginx_assets_regex }} {
Expand Down

0 comments on commit 8669148

Please sign in to comment.