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