diff --git a/CHANGELOG.md b/CHANGELOG.md index 4e909da8..3755ca00 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,7 +9,6 @@ BUG FIXES: * NGINX listen `so_keepalive` parameter was not working as intended when setting specific values. * Make sure all template objects are properly transformed into strings before doing Jinja2 operations. * Remove unnecessary parentheses. -* Fix rewrite option in modules template. ## 0.4.1 (October 25, 2021) diff --git a/defaults/main/template.yml b/defaults/main/template.yml index 7613470f..ea2a3451 100644 --- a/defaults/main/template.yml +++ b/defaults/main/template.yml @@ -175,7 +175,7 @@ nginx_config_http_template: etag: true # Boolean if_modified_since: exact # Can be set to 'off', 'exact' or 'before' ignore_invalid_headers: true # Boolean -- Not available in the 'location' context - include: path # Note -- This directive originally belongs in the NGINX core module, but we are making an exception here + include: path # String or list. Note -- This directive originally belongs in the NGINX core module, but we are making an exception here. index: path # Note -- This directive originally belongs in the NGINX index module, but we are making an exception here internal: false # Boolean -- Only available in the 'location' context keepalive_disable: msie6 # String or a list @@ -685,7 +685,7 @@ nginx_config_http_template: last_modified: false # Boolean once: true # Boolean types: text/html # String or a list - custom_directives: # Custom directive for specific use cases not covered by templates -- you need to add a semi-colon at the end of each directive + custom_directives: # String or list. Custom directive for specific use cases not covered by templates -- you need to add a semi-colon at the end of each directive. - fastcgi_split_path_info ^(.+\.php)(/.+)$; - fastcgi_pass unix:/run/php/php7.2-fpm.sock; servers: diff --git a/templates/http/auth.j2 b/templates/http/auth.j2 index 873bf59e..e317186c 100644 --- a/templates/http/auth.j2 +++ b/templates/http/auth.j2 @@ -48,14 +48,14 @@ auth_request_set {{ auth_request['set']['variable'] }} {{ auth_request['set']['v auth_jwt {{ 'off' if not auth_jwt['enable'] }}{{ auth_jwt['enable']['realm'] if auth_jwt['enable']['realm'] is defined }}{{ (' token=' + auth_jwt['enable']['token'] | string) if auth_jwt['enable']['token'] is defined }}; {% endif %} {% if auth_jwt['claim_set'] is defined %}{# 'claim_set' is only available in the 'http' context #} -{% for claim in auth_jwt['claim_set'] if (auth_jwt['claim_set'] is not mapping and auth_jwt['claim_set'] is not string) %} +{% for claim in auth_jwt['claim_set'] if auth_jwt['claim_set'] is not mapping %} auth_jwt_claim_set {{ claim['variable'] }} {{ (claim['name'] if claim['name'] is string else claim['name'] | join(' ')) }}; {% else %} auth_jwt_claim_set {{ auth_jwt['claim_set']['variable'] }} {{ (auth_jwt['claim_set']['name'] if auth_jwt['claim_set']['name'] is string else auth_jwt['claim_set']['name'] | join(' ')) }}; {% endfor %} {% endif %} {% if auth_jwt['header_set'] is defined %}{# 'header_set' is only available in the 'http' context #} -{% for claim in auth_jwt['header_set'] if (auth_jwt['header_set'] is not mapping and auth_jwt['header_set'] is not string) %} +{% for claim in auth_jwt['header_set'] if auth_jwt['header_set'] is not mapping %} auth_jwt_header_set {{ claim['variable'] }} {{ (claim['name'] if claim['name'] is string else claim['name'] | join(' ')) }}; {% else %} auth_jwt_header_set {{ auth_jwt['header_set']['variable'] }} {{ (auth_jwt['header_set']['name'] if auth_jwt['header_set']['name'] is string else auth_jwt['header_set']['name'] | join(' ')) }}; diff --git a/templates/http/core.j2 b/templates/http/core.j2 index 0cba500b..929c3862 100644 --- a/templates/http/core.j2 +++ b/templates/http/core.j2 @@ -85,7 +85,7 @@ if_modified_since {{ 'off' if not core['if_modified_since'] else core['if_modifi {% if core['ignore_invalid_headers'] is defined and core['ignore_invalid_headers'] is boolean %}{# 'ignore_invalid_headers' directive is not available in the 'location' context #} ignore_invalid_headers {{ core['ignore_invalid_headers'] | ternary('on', 'off') }}; {% endif %} -{% if core['include'] is defined and (core['include'] is string or core['include'] is sequence) %}{# ngx_core_module #}{# This does not belong here but we are making an exception #} +{% if core['include'] is defined and core['include'] is not mapping %}{# ngx_core_module #}{# This does not belong here but we are making an exception #} {% for file in core['include'] if core['include'] is not string %} include {{ file }}; {% else %} diff --git a/templates/http/default.conf.j2 b/templates/http/default.conf.j2 index 4cec202a..30ff2a7f 100644 --- a/templates/http/default.conf.j2 +++ b/templates/http/default.conf.j2 @@ -88,7 +88,7 @@ {% from 'http/modules.j2' import sub_filter with context %} {{ sub_filter(item['config']['sub_filter']) }} {%- endif %} -{% if item['config']['custom_directives'] is defined and item['config']['custom_directives'] is sequence %} +{% if item['config']['custom_directives'] is defined and item['config']['custom_directives'] is not mapping %} {% for directive in item['config']['custom_directives'] if item['config']['custom_directives'] is not string %} {{ directive }} {% else %} @@ -222,7 +222,7 @@ server { {{ sub_filter(server['sub_filter']) }} {%- endfilter %} {% endif %} -{% if server['custom_directives'] is defined and server['custom_directives'] is sequence %} +{% if server['custom_directives'] is defined and server['custom_directives'] is not mapping %} {% for directive in server['custom_directives'] if server['custom_directives'] is not string %} {% filter indent(4) %} {{ directive }} @@ -352,7 +352,7 @@ server { {{ sub_filter(location['sub_filter']) }} {%- endfilter %} {% endif %} -{% if location['custom_directives'] is defined and location['custom_directives'] is sequence %} +{% if location['custom_directives'] is defined and location['custom_directives'] is not mapping %} {% for directive in location['custom_directives'] if location['custom_directives'] is not string %} {% filter indent(8) %} {{ directive }} diff --git a/templates/http/modules.j2 b/templates/http/modules.j2 index 75177a92..8c391d40 100644 --- a/templates/http/modules.j2 +++ b/templates/http/modules.j2 @@ -199,15 +199,17 @@ open_log_file_cache {{ 'off' if not log['open_log_file_cache'] else ('max=' + lo return {{ rewrite['return'] if (rewrite['return'] is string or rewrite['return'] is number) }}{{ rewrite['return']['code'] if rewrite['return']['code'] is defined }}{{ (' ' + rewrite['return']['text'] | string) if rewrite['return']['text'] is defined }}{{ (' ' + rewrite['return']['url'] | string) if rewrite['return']['url'] is defined }}; {% endif %} {% if rewrite['rewrites'] is defined %}{# 'rewrite' directive is not available in the 'http' context #} -{% for rewrite in rewrite['rewrites'] if (rewrite['rewrites'] is not mapping and rewrite['rewrites'] is not string) %} +{% for rewrite in rewrite['rewrites'] if rewrite['rewrites'] is not mapping %} rewrite {{ rewrite['regex'] }} {{ rewrite['replacement'] }}{{ (' ' + rewrite['flag'] | string) if rewrite['flag'] is defined and rewrite['flag'] in ['last', 'break', 'redirect', 'permanent'] }}; +{% else %} +rewrite {{ rewrite['rewrites']['regex'] }} {{ rewrite['rewrites']['replacement'] }}{{ (' ' + rewrite['rewrites']['flag'] | string) if rewrite['rewrites']['flag'] is defined and rewrite['rewrites']['flag'] in ['last', 'break', 'redirect', 'permanent'] }}; {% endfor %} {% endif %} {% if rewrite['log'] is defined and rewrite['log'] is boolean %} rewrite_log {{ rewrite['log'] | ternary('on', 'off') }}; {% endif %} {% if rewrite['set'] is defined %}{# 'set' directive is not available in the 'http' context #} -{% for set in rewrite['set'] if (rewrite['set'] is not mapping and rewrite['set'] is not string) %} +{% for set in rewrite['set'] if rewrite['set'] is not mapping %} set {{ set['variable'] }} {{ set['value'] }}; {% else %} set {{ rewrite['set']['variable'] }} {{ rewrite['set']['value'] }};