102 lines
2.7 KiB
Django/Jinja
102 lines
2.7 KiB
Django/Jinja
server {
|
|
listen 80;
|
|
server_name {{ inventory_hostname }};
|
|
|
|
location = /server_status {
|
|
stub_status;
|
|
access_log off;
|
|
|
|
allow 127.0.0.1;
|
|
{% if 'address' in ansible_default_ipv4 -%}
|
|
allow {{ ansible_default_ipv4.address }};
|
|
{% endif -%}
|
|
deny all;
|
|
}
|
|
location / {
|
|
return 301 https://$host$request_uri;
|
|
}
|
|
}
|
|
|
|
server {
|
|
listen 443 ssl default_server;
|
|
{% if nginx_http2 -%}
|
|
http2 on;
|
|
{% else -%}
|
|
#http2 off;
|
|
{% endif %}
|
|
|
|
# listen [::]:443 ssl; # listen for ipv6
|
|
|
|
root /var/www/html;
|
|
|
|
include /etc/nginx/well-known.conf;
|
|
include /etc/nginx/sudo-known.conf;
|
|
include /etc/nginx/authelia_internal.conf;
|
|
|
|
location = /server_status {
|
|
stub_status;
|
|
|
|
access_log off;
|
|
|
|
allow 127.0.0.1;
|
|
{% if 'address' in ansible_default_ipv4 -%}
|
|
allow {{ ansible_default_ipv4.address }};
|
|
{% endif -%}
|
|
{% if ansible_default_ipv6 is defined and 'address' in ansible_default_ipv6 -%}
|
|
allow {{ ansible_default_ipv6.address }};
|
|
{% endif -%}
|
|
allow {{ bridgewithdns_cidr }};
|
|
deny all;
|
|
}
|
|
|
|
|
|
{% for item in nginx_redirect|default([]) %}
|
|
location = {{ item.src }} {
|
|
return 301 https://$host{{ item.dest }};
|
|
}
|
|
{% endfor %}
|
|
|
|
{% for item in nginx_subdirs %}
|
|
location ^~ /{{ item.dir }}/ {
|
|
{% if item.require_auth | default(False) -%}
|
|
include /etc/nginx/require_auth.conf;
|
|
include /etc/nginx/require_auth_proxy.conf;
|
|
{% endif %}
|
|
|
|
proxy_set_header Host $host;
|
|
proxy_set_header X-Real-IP $remote_addr;
|
|
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
|
|
|
proxy_pass {{ item.proxy_pass }};
|
|
rewrite /{{ item.dir }}(.*) $1 break;
|
|
|
|
}
|
|
{% endfor %}
|
|
|
|
{% if nginx_default_site_autoindex|default(False) -%}
|
|
autoindex on;
|
|
autoindex_exact_size off;
|
|
{% endif -%}
|
|
|
|
access_log /var/log/nginx/access.log main;
|
|
error_log /var/log/nginx/error.log warn;
|
|
|
|
ssl_session_timeout 5m;
|
|
|
|
{% if inventory_hostname == ansible_control_host -%}
|
|
ssl_certificate /usr/local/etc/certs/{{ inventory_hostname }}/fullchain.pem;
|
|
ssl_certificate_key /usr/local/etc/certs/{{ inventory_hostname }}/privkey.pem;
|
|
{% else -%}
|
|
ssl_certificate /usr/local/etc/certs/nginx_default_cert/pubkey.pem;
|
|
ssl_certificate_key /usr/local/etc/certs/nginx_default_cert/privkey.pem;
|
|
{% endif %}
|
|
|
|
add_header Referrer-Policy "no-referrer" always;
|
|
add_header X-Content-Type-Options "nosniff" always;
|
|
add_header X-Download-Options "noopen" always;
|
|
add_header X-Frame-Options "SAMEORIGIN" always;
|
|
add_header X-Permitted-Cross-Domain-Policies "none" always;
|
|
add_header X-Robots-Tag "none" always;
|
|
add_header X-XSS-Protection "1; mode=block" always;
|
|
}
|