diff --git a/states/nginx/templates/types/dokuwiki.j2 b/states/nginx/templates/types/dokuwiki.j2 index 76fd26b..c154ad6 100644 --- a/states/nginx/templates/types/dokuwiki.j2 +++ b/states/nginx/templates/types/dokuwiki.j2 @@ -13,6 +13,19 @@ server { index index.php index.html; + {%- if internal and not auth %} + if ($allow = false) { + return 403; + } + {%- endif %} + if ($allow = true) { + set $auth "off"; + } + {%- if auth %} + auth_basic $auth; + auth_basic_user_file {{ config_dir }}/auth/htpasswd; + {%- endif %} + {%- for key,value in headers.items() %} add_header {{ key }} "{{ value }}"; {%- endfor %} diff --git a/states/nginx/templates/types/nextcloud.j2 b/states/nginx/templates/types/nextcloud.j2 index e43d597..43ffbab 100644 --- a/states/nginx/templates/types/nextcloud.j2 +++ b/states/nginx/templates/types/nextcloud.j2 @@ -16,6 +16,20 @@ server { error_page 404 /core/templates/404.php; client_max_body_size 4G; fastcgi_buffers 64 4K; + + {%- if internal and not auth %} + if ($allow = false) { + return 403; + } + {%- endif %} + if ($allow = true) { + set $auth "off"; + } + {%- if auth %} + auth_basic $auth; + auth_basic_user_file {{ config_dir }}/auth/htpasswd; + {%- endif %} + add_header Strict-Transport-Security "max-age=31536000; includeSubDomains" always; {%- for key,value in headers.items() %} add_header {{ key }} "{{ value }}"; diff --git a/states/nginx/templates/types/zabbix.j2 b/states/nginx/templates/types/zabbix.j2 index 8767281..dbf1084 100644 --- a/states/nginx/templates/types/zabbix.j2 +++ b/states/nginx/templates/types/zabbix.j2 @@ -13,6 +13,19 @@ server { index index.php index.html; + {%- if internal and not auth %} + if ($allow = false) { + return 403; + } + {%- endif %} + if ($allow = true) { + set $auth "off"; + } + {%- if auth %} + auth_basic $auth; + auth_basic_user_file {{ config_dir }}/auth/htpasswd; + {%- endif %} + {%- for key,value in headers.items() %} add_header {{ key }} "{{ value }}"; {%- endfor %}