Add optional IP restriction for nginx site configs

This commit is contained in:
Kris Lamoureux 2024-10-19 21:08:15 -04:00
parent e3f03edf3f
commit 3102c621f0
Signed by: kris
GPG Key ID: 3EDA9C3441EDA925

View File

@ -35,7 +35,13 @@ server {
client_max_body_size {{ item.client_max_body_size }};
{% endif %}
location / {
{% if item.restrict is defined and item.restrict %}
{% if item.allowedips is defined %}
{% for ip in item.allowedips %}
allow {{ ip }};
{% endfor %}
deny all;
{% endif %}
{% if item.restrict is defined and item.restrict %}
auth_basic "{{ item.restrict_name | default('Restricted Access') }}";
auth_basic_user_file {{ item.restrict_file | default('/etc/nginx/.htpasswd') }};
proxy_set_header Authorization "";