From e90e77bf531a17e35c52e3fd38e0f61263faaeda Mon Sep 17 00:00:00 2001 From: Paul Lecuq Date: Fri, 26 Aug 2022 20:50:00 +0200 Subject: [PATCH] updated nginx state --- states/nginx/templates/types/dip.j2 | 89 +++++++++++++++++++++++++++++ 1 file changed, 89 insertions(+) create mode 100644 states/nginx/templates/types/dip.j2 diff --git a/states/nginx/templates/types/dip.j2 b/states/nginx/templates/types/dip.j2 new file mode 100644 index 0000000..c45d181 --- /dev/null +++ b/states/nginx/templates/types/dip.j2 @@ -0,0 +1,89 @@ +## {{ salt['pillar.get']('salt_managed', default='Salt Managed') }} + +server { + include http; + server_name {{ vhost_name }}; + if ($http_accept != '*/*') { + return 301 https://$server_name$request_uri; + } + + server_name {{ vhost_name }}; + {%- if not proxy %} + root "{{ root_dir }}"; + {%- endif %} + + {%- for key,value in headers.items() %} + add_header {{ key }} "{{ value }}"; + {%- endfor %} + + location / { + {%- if proxy %} + proxy_pass {{ proxy_pass }}; + {%- if not cache %} + proxy_no_cache 1; + proxy_cache_bypass 1; + {%- endif %} + {%- endif %} + {%- if autoindex %} + autoindex on; + autoindex_localtime on; + {%- else %} + index index.html index.rss; + {% endif %} + } + + {%- for dir in dirs %} + location {{ dir.name }} { + alias {{ dir.alias }}; + } + {%- endfor %} + + location /robots.txt { + return 200 "User-agent: *\r\nDisallow: /"; + } +} + +server { + include https; + {%- if internal_access %} + include access; + {%- endif %} + server_name {{ vhost_name }}; + {%- if not proxy %} + root "{{ root_dir }}"; + {%- endif %} + + {%- for key,value in headers.items() %} + add_header {{ key }} "{{ value }}"; + {%- endfor %} + + location / { + {%- if proxy %} + proxy_pass {{ proxy_pass }}; + {%- if not cache %} + proxy_no_cache 1; + proxy_cache_bypass 1; + {%- endif %} + {%- endif %} + {%- if autoindex %} + autoindex on; + autoindex_localtime on; + {%- else %} + index index.html index.rss; + {% endif %} + {%- if auth %} + auth_basic "Restricted area"; + auth_basic_user_file {{ config_dir }}/auth/htpasswd; + {%- endif %} + } + + {%- for dir in dirs %} + location {{ dir.name }} { + alias {{ dir.alias }}; + } + {%- endfor %} + + location /robots.txt { + return 200 "User-agent: *\r\nDisallow: /"; + } +}