diff --git a/defaults/main.yml b/defaults/main.yml index 1b440a1..f31b0ab 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -159,14 +159,15 @@ nginx_vhosts_default: # dhparam: # client_max_body_size: # send_timeout: +# add_headers: +# - name: +# value: +# always: True # locations: # - match: / # root: /var/www/vhosts/default # index: index.html -# add_headers: -# - name: -# value: -# always: True +# add_headers: [] # proxy_pass: # proxy_http_version: "1.1" # proxy_buffering: "off" diff --git a/templates/etc/nginx/sites-available/vhost.j2 b/templates/etc/nginx/sites-available/vhost.j2 index 605dd3e..66961bd 100644 --- a/templates/etc/nginx/sites-available/vhost.j2 +++ b/templates/etc/nginx/sites-available/vhost.j2 @@ -37,6 +37,13 @@ server { {% if server.send_timeout is defined and server.send_timeout %} send_timeout {{ server.send_timeout }}; {% endif %} + {% if server.add_headers is defined and server.add_headers %} + + include /etc/nginx/conf.d/header.conf; + {% for add in server.add_headers %} + add_header {{ add.name }} {{ add.value }}{{ " always" if add.always | default(True) | bool else "" }}; + {% endfor %} + {% endif %} {% if server.custom_options is defined and server.custom_options %} {% for inline_option in server.custom_options %}