mirror of
https://github.com/HanXHX/ansible-nginx.git
synced 2026-03-10 10:12:09 +07:00
New feature: custom location in vhost
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
{% set __listen = item.listen | default(['80']) %}
|
||||
{% set __listen_ssl = item.listen_ssl | default(['443']) %}
|
||||
{% set __location = item.location | default({}) %}
|
||||
#
|
||||
# {{ ansible_managed }}
|
||||
#
|
||||
@@ -45,6 +46,17 @@ server {
|
||||
log_not_found off;
|
||||
}
|
||||
|
||||
{% if __location is iterable and __location | length > 0 %}
|
||||
# --> Custom locations
|
||||
{% for location, opts in __location.iteritems() %}
|
||||
location {{ location }} {
|
||||
{% for opt in opts %}
|
||||
{{ opt }}
|
||||
{% endfor %}
|
||||
}
|
||||
{% endfor %} # <-- Custom locations
|
||||
{% endif %}
|
||||
|
||||
{% if item.use_access_log is defined and item.use_access_log %}
|
||||
access_log {{ nginx_log_dir }}/{{ item.name }}_access.log combined;
|
||||
{% else %}
|
||||
|
||||
@@ -19,6 +19,11 @@
|
||||
- 'test-alias.local'
|
||||
- 'test2-alias.local'
|
||||
template: '_base'
|
||||
location:
|
||||
'/test':
|
||||
- 'return 403;'
|
||||
'/gunther':
|
||||
- 'return 404;'
|
||||
- name:
|
||||
- 'test-php.local'
|
||||
redirect_from:
|
||||
|
||||
Reference in New Issue
Block a user