You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

75 lines
3.3 KiB

add_header X-Frame-Options SAMEORIGIN;
add_header X-Content-Type-Options nosniff;
add_header X-XSS-Protection "1; mode=block";
add_header Content-Security-Policy "default-src 'self'; script-src 'self' 'unsafe-inline' 'unsafe-eval' https://www.google-analytics.com; img-src 'self' data: https://www.google-analytics.com; style-src 'self' 'unsafe-inline'; font-src 'self'; frame-src 'none'; object-src 'none'";
# HTTPS server
#
{% for nginx_host in nginx_hosts %}
server {
listen 0.0.0.0:443 ssl{% if nginx_host.default is defined and nginx_host.default is sameas true %} default{% endif %};
server_name {{ nginx_host.domain_name }};
{% if nginx_host.nginx_satisfy is defined and nginx_host.nginx_satisfy is not sameas none %}
satisfy {{ nginx_host.nginx_satisfy }};
{% endif %}
{% if nginx_host.nginx_allow is defined and nginx_host.nginx_allow|length > 0 %}
{% for nginx_allowed in nginx_host.nginx_allow %}
allow {{ nginx_allowed }};
{% endfor %}
{% endif %}
{% if nginx_host.nginx_deny is defined and nginx_host.nginx_deny|length > 0 %}
{% for nginx_denied in nginx_host.nginx_deny %}
deny {{ nginx_denied }};
{% endfor %}
{% endif %}
{% if nginx_host.users is defined and nginx_host.users|length > 0 %}
auth_basic "{{ nginx_host.domain_name }}";
auth_basic_user_file /etc/nginx/{{ nginx_host.domain_name }}.htpasswd;
{% endif %}
{% if nginx_single_cert is defined and nginx_single_cert is sameas true %}
ssl_certificate /etc/letsencrypt/live/{{ nginx_hosts | map(attribute='domain_name') | first }}/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/{{ nginx_hosts | map(attribute='domain_name') | first }}/privkey.pem;
ssl_trusted_certificate /etc/letsencrypt/live/{{ nginx_hosts | map(attribute='domain_name') | first }}/fullchain.pem;
{% else %}
ssl_certificate /etc/letsencrypt/live/{{ nginx_host.domain_name }}/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/{{ nginx_host.domain_name }}/privkey.pem;
ssl_trusted_certificate /etc/letsencrypt/live/{{ nginx_host.domain_name }}/fullchain.pem;
{% endif %}
ssl_session_cache shared:SSL:50m;
ssl_session_timeout 5m;
ssl_stapling on;
ssl_stapling_verify on;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_ciphers "ECDHE-RSA-AES256-GCM-SHA384:ECDHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384:DHE-RSA-AES128-GCM-SHA256:ECDHE-RSA-AES256-SHA384:ECDHE-RSA-AES128-SHA256:ECDHE-RSA-AES256-SHA:ECDHE-RSA-AES128-SHA:DHE-RSA-AES256-SHA256:DHE-RSA-AES128-SHA256:DHE-RSA-AES256-SHA:DHE-RSA-AES128-SHA:ECDHE-RSA-DES-CBC3-SHA:EDH-RSA-DES-CBC3-SHA:AES256-GCM-SHA384:AES128-GCM-SHA256:AES256-SHA256:AES128-SHA256:AES256-SHA:AES128-SHA:DES-CBC3-SHA:HIGH:!aNULL:!eNULL:!EXPORT:!DES:!MD5:!PSK:!RC4";
ssl_dhparam /etc/nginx/dhparams.pem;
ssl_prefer_server_ciphers on;
{% if nginx_host.reverse_hosts is defined and nginx_host.reverse_hosts|length > 0 %}
{% for proxy in nginx_host.reverse_hosts %}
location {{ proxy.path }} {
proxy_pass {{ proxy.protocol }}://{{ proxy.host }}:{{ proxy.port }};
{% if proxy.extra is defined %}
{{ proxy.extra }}
{% endif %}
}
{% endfor %}
{% else %}
root /var/www/{{ nginx_host.domain_name }};
index index.html index.htm;
location / {
try_files $uri $uri/ =404;
}
{% endif %}
{% if nginx_host.extra is defined %}
{{ nginx_host.extra }}
{% endif %}
}
{% endfor %}