From 02c8e0a74588680e4a2261d5bd8298274a54468c Mon Sep 17 00:00:00 2001 From: Robert Kaussow Date: Fri, 22 May 2020 21:30:03 +0200 Subject: [PATCH] move maps to http context in nginx.conf --- defaults/main.yml | 16 ++++++++++------ templates/etc/nginx/nginx.conf.j2 | 7 +++++++ templates/etc/nginx/sites-available/vhost.j2 | 11 ----------- 3 files changed, 17 insertions(+), 17 deletions(-) diff --git a/defaults/main.yml b/defaults/main.yml index 7d24027..71797ec 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -88,6 +88,16 @@ nginx_xxxsp_enabled: True nginx_xxxsp_parameters: - mode=block +nginx_maps: [] +# @var nginx_maps:example: > +# nginx_maps: +# - input: $input +# output: $output +# parameters: +# - "default 0" +# - "/old/path /new_path" +# @end + nginx_vhosts_dir: /var/www/vhosts nginx_vhosts_default: @@ -117,12 +127,6 @@ nginx_vhosts_default: # dhparam: # client_max_body_size: # send_timeout: -# maps: -# - input: $input -# output: $output -# parameters: -# - "default 0" -# - "/old/path /new_path" # locations: # - match: / # root: /var/www/vhosts/default diff --git a/templates/etc/nginx/nginx.conf.j2 b/templates/etc/nginx/nginx.conf.j2 index 8797a2e..283ea55 100644 --- a/templates/etc/nginx/nginx.conf.j2 +++ b/templates/etc/nginx/nginx.conf.j2 @@ -33,6 +33,13 @@ http { default upgrade; '' close; } + {% for map in nginx_maps %} + map {{ map.input }} {{ map.output }} { + {% for param in map.parameters %} + {{ param }}; + {% endfor %} + } + {% endfor %} sendfile on; tcp_nopush on; diff --git a/templates/etc/nginx/sites-available/vhost.j2 b/templates/etc/nginx/sites-available/vhost.j2 index 842ad34..2167b8f 100644 --- a/templates/etc/nginx/sites-available/vhost.j2 +++ b/templates/etc/nginx/sites-available/vhost.j2 @@ -36,17 +36,6 @@ server { {% endif %} {% if server.send_timeout is defined and server.send_timeout %} send_timeout {{ server.send_timeout }}; - {% endif %} - {% if server.maps is defined and server.maps %} - - {% for map in server.maps %} - map {{ map.input }} {{ map.output }} { - {% for param in map.parameters %} - {{ param }}; - {% endfor %} - } - {% endfor %} - {% endif %} {% for location in server.locations %} location {{ location.match }} {