2016-07-03 12:19:12 +02:00
|
|
|
server {
|
2018-05-16 18:27:27 +02:00
|
|
|
listen {{ item.http_port | default ('80') }};
|
2016-07-03 12:19:12 +02:00
|
|
|
server_name {{ item.server_name }} {% if item.serveraliases is defined %}{{ item.serveraliases }}{% endif %};
|
2017-11-07 00:09:01 +01:00
|
|
|
location ~ /\.(?!well-known).* {
|
|
|
|
deny all;
|
|
|
|
access_log off;
|
|
|
|
log_not_found off;
|
2017-11-15 01:05:07 +01:00
|
|
|
return 404;
|
2017-11-07 00:09:01 +01:00
|
|
|
}
|
2018-07-03 17:03:10 +02:00
|
|
|
|
2016-11-09 14:27:00 +01:00
|
|
|
{% if letsencrypt_acme_install %}
|
|
|
|
include /etc/nginx/snippets/letsencrypt-proxy.conf;
|
|
|
|
{% endif %}
|
2018-07-03 17:03:10 +02:00
|
|
|
|
2016-07-03 12:19:12 +02:00
|
|
|
{% if item.access_log is defined %}
|
|
|
|
access_log {{ item.access_log }};
|
|
|
|
{% else %}
|
|
|
|
access_log /var/log/nginx/{{ item.server_name }}_access.log;
|
|
|
|
{% endif %}
|
2018-07-03 17:03:10 +02:00
|
|
|
|
2016-07-03 12:19:12 +02:00
|
|
|
{% if item.error_log is defined %}
|
|
|
|
error_log {{ item.error_log }};
|
|
|
|
{% else %}
|
|
|
|
error_log /var/log/nginx/{{ item.server_name }}_error.log;
|
|
|
|
{% endif %}
|
2018-07-03 17:03:10 +02:00
|
|
|
|
2016-11-09 14:27:00 +01:00
|
|
|
server_tokens {{ item.server_tokens | default('off') }};
|
2018-07-03 17:03:10 +02:00
|
|
|
|
2016-11-09 14:27:00 +01:00
|
|
|
{% if item.ssl_enabled and item.ssl_only %}
|
|
|
|
location / {
|
2017-02-01 17:12:54 +01:00
|
|
|
return 301 https://{{ item.server_name }}$request_uri;
|
2016-11-09 14:27:00 +01:00
|
|
|
}
|
|
|
|
{% else %}
|
|
|
|
root {{ item.root | default('/usr/share/nginx/html/') }};
|
|
|
|
index {{ item.index | default('index.html index.htm') }};
|
|
|
|
error_page 500 502 503 504 {{ item.error_page | default('/50x.html') }};
|
2016-07-03 12:19:12 +02:00
|
|
|
location = /50x.html {
|
|
|
|
root /usr/share/nginx/html;
|
|
|
|
}
|
|
|
|
location = /favicon.ico {
|
|
|
|
log_not_found off;
|
|
|
|
access_log off;
|
|
|
|
}
|
|
|
|
location = /robots.txt {
|
|
|
|
allow all;
|
|
|
|
log_not_found off;
|
|
|
|
access_log off;
|
|
|
|
}
|
2017-11-07 00:09:01 +01:00
|
|
|
location ~ /\. {
|
|
|
|
deny all;
|
|
|
|
access_log off;
|
|
|
|
log_not_found off;
|
2017-11-15 01:05:07 +01:00
|
|
|
return 404;
|
2017-11-07 00:09:01 +01:00
|
|
|
}
|
2016-11-09 14:27:00 +01:00
|
|
|
{% if haproxy_ips is defined %}
|
|
|
|
# We are behind haproxy
|
|
|
|
{% for ip in haproxy_ips %}
|
|
|
|
set_real_ip_from {{ ip }};
|
|
|
|
{% endfor %}
|
|
|
|
real_ip_header X-Forwarded-For;
|
|
|
|
{% endif %}
|
2018-07-03 17:03:10 +02:00
|
|
|
|
2016-07-03 12:19:12 +02:00
|
|
|
{% if item.max_body is defined %}
|
|
|
|
client_max_body_size {{ item.max_body }};
|
|
|
|
{% else %}
|
|
|
|
client_max_body_size {{ nginx_client_max_body_size }};
|
|
|
|
{% endif %}
|
2018-07-03 17:03:10 +02:00
|
|
|
|
2016-07-03 12:19:12 +02:00
|
|
|
{% if item.body_timeout is defined %}
|
|
|
|
client_body_timeout {{ item.body_timeout }};
|
|
|
|
{% else %}
|
|
|
|
client_body_timeout {{ nginx_client_body_timeout }};
|
|
|
|
{% endif %}
|
|
|
|
|
2018-07-03 17:03:10 +02:00
|
|
|
server_tokens {{ item.server_tokens | default('off') }};
|
|
|
|
|
2018-02-27 14:17:11 +01:00
|
|
|
{% if nginx_cors_enabled %}
|
|
|
|
{% if nginx_cors_global %}
|
|
|
|
include /etc/nginx/snippets/nginx-cors.conf;
|
|
|
|
{% endif %}
|
|
|
|
{% endif %}
|
|
|
|
|
2017-03-16 11:37:10 +01:00
|
|
|
{% if item.additional_options is defined %}
|
|
|
|
{% for add_opt in item.additional_options %}
|
|
|
|
{{ add_opt }};
|
2018-07-03 17:03:10 +02:00
|
|
|
{% endfor %}
|
|
|
|
{% endif %}
|
2017-03-16 11:37:10 +01:00
|
|
|
|
2018-07-03 17:03:10 +02:00
|
|
|
{% if item.http_acls is defined %}
|
|
|
|
{% for acl in item.http_acls %}
|
|
|
|
{{ acl }};
|
2017-03-16 11:37:10 +01:00
|
|
|
{% endfor %}
|
|
|
|
{% endif %}
|
|
|
|
|
2016-11-09 14:27:00 +01:00
|
|
|
{% if item.websockets is defined and item.websockets %}
|
|
|
|
proxy_set_header Upgrade $http_upgrade;
|
|
|
|
proxy_set_header Connection $connection_upgrade;
|
|
|
|
{% endif %}
|
2018-07-03 17:03:10 +02:00
|
|
|
|
2016-07-03 12:19:12 +02:00
|
|
|
{% if item.proxy_standard_setup is defined and item.proxy_standard_setup %}
|
2018-07-03 17:03:10 +02:00
|
|
|
|
2016-07-03 12:19:12 +02:00
|
|
|
# Proxy stuff
|
2017-11-23 17:48:56 +01:00
|
|
|
{% if item.include_global_proxy_conf is defined and not item.include_global_proxy_conf %}
|
|
|
|
{% else %}
|
2016-11-09 14:27:00 +01:00
|
|
|
include /etc/nginx/snippets/nginx-proxy-params.conf;
|
2017-11-23 17:48:56 +01:00
|
|
|
{% endif %}
|
2018-07-03 17:03:10 +02:00
|
|
|
|
2016-07-03 12:19:12 +02:00
|
|
|
{% if item.proxy_additional_options is defined %}
|
|
|
|
{% for popt in item.proxy_additional_options %}
|
2017-03-16 11:37:10 +01:00
|
|
|
{{ popt }};
|
2016-07-03 12:19:12 +02:00
|
|
|
{% endfor %}
|
2016-11-09 14:27:00 +01:00
|
|
|
{% endif %}
|
2018-07-03 17:03:10 +02:00
|
|
|
|
2017-02-01 17:12:54 +01:00
|
|
|
{% if item.locations is defined %}
|
|
|
|
{% for location in item.locations %}
|
2018-07-03 17:03:10 +02:00
|
|
|
|
2017-02-01 17:12:54 +01:00
|
|
|
location {{ location.location }} {
|
2018-07-03 17:03:10 +02:00
|
|
|
|
2018-02-27 14:17:11 +01:00
|
|
|
{% if nginx_cors_enabled %}
|
|
|
|
{% if not nginx_cors_global %}
|
|
|
|
{% if location.cors is defined and location.cors %}
|
|
|
|
include /etc/nginx/snippets/nginx-cors.conf;
|
|
|
|
{% endif %}
|
|
|
|
{% endif %}
|
|
|
|
{% endif %}
|
2018-07-03 17:03:10 +02:00
|
|
|
|
2017-02-01 17:12:54 +01:00
|
|
|
{% if location.target is defined %}
|
|
|
|
proxy_pass {{ location.target }};
|
|
|
|
{% endif %}
|
2018-07-03 17:03:10 +02:00
|
|
|
|
2017-03-16 11:37:10 +01:00
|
|
|
{% if location.extra_conf is defined %}
|
|
|
|
{{ location.extra_conf }}
|
|
|
|
{% endif %}
|
2018-07-03 17:03:10 +02:00
|
|
|
|
|
|
|
{% if location.acls is defined %}
|
|
|
|
{% for acl in location.acls %}
|
|
|
|
{{ acl }};
|
|
|
|
{% endfor %}
|
|
|
|
{% endif %}
|
|
|
|
|
|
|
|
{% if location.other_opts is defined %}
|
2017-02-01 17:12:54 +01:00
|
|
|
{% for opt in location.other_opts %}
|
|
|
|
{{ opt }};
|
|
|
|
{% endfor %}
|
|
|
|
{% endif %}
|
2018-07-03 17:03:10 +02:00
|
|
|
}
|
2016-11-09 14:27:00 +01:00
|
|
|
{% endfor %}
|
|
|
|
{% endif %}
|
|
|
|
{% endif %}
|
2018-07-03 17:03:10 +02:00
|
|
|
|
2016-11-09 14:27:00 +01:00
|
|
|
{% if item.extra_parameters is defined %}
|
|
|
|
{{ item.extra_parameters }}
|
2017-02-01 17:12:54 +01:00
|
|
|
{% endif %}
|
2018-07-03 17:03:10 +02:00
|
|
|
|
2016-07-03 12:19:12 +02:00
|
|
|
{% endif %}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2017-08-18 15:47:17 +02:00
|
|
|
{% if item.ssl_enabled %}
|
2016-07-03 12:19:12 +02:00
|
|
|
server {
|
2018-05-16 18:27:27 +02:00
|
|
|
listen {{ https_port | default('443') }} {{ nginx_ssl_type }};
|
2016-11-09 14:27:00 +01:00
|
|
|
server_name {{ item.server_name }} {% if item.serveraliases is defined %}{{ item.serveraliases }}{% endif %};
|
2018-07-03 17:03:10 +02:00
|
|
|
|
2016-11-09 14:27:00 +01:00
|
|
|
{% if item.access_log is defined %}
|
|
|
|
access_log {{ item.access_log }};
|
|
|
|
{% else %}
|
|
|
|
access_log /var/log/nginx/{{ item.server_name }}_ssl_access.log;
|
|
|
|
{% endif %}
|
2018-07-03 17:03:10 +02:00
|
|
|
|
2016-11-09 14:27:00 +01:00
|
|
|
{% if item.error_log is defined %}
|
|
|
|
error_log {{ item.error_log }};
|
|
|
|
{% else %}
|
|
|
|
error_log /var/log/nginx/{{ item.server_name }}_ssl_error.log;
|
|
|
|
{% endif %}
|
2018-07-03 17:03:10 +02:00
|
|
|
|
2016-11-09 14:27:00 +01:00
|
|
|
root {{ item.root | default('/usr/share/nginx/html/') }};
|
|
|
|
index {{ item.index | default('index.html index.htm') }};
|
|
|
|
error_page 500 502 503 504 {{ item.error_page | default('/50x.html') }};
|
2016-07-03 12:19:12 +02:00
|
|
|
location = /50x.html {
|
2016-11-09 14:27:00 +01:00
|
|
|
root /usr/share/nginx/html;
|
2016-07-03 12:19:12 +02:00
|
|
|
}
|
|
|
|
location = /favicon.ico {
|
|
|
|
log_not_found off;
|
|
|
|
access_log off;
|
|
|
|
}
|
|
|
|
location = /robots.txt {
|
|
|
|
allow all;
|
|
|
|
log_not_found off;
|
|
|
|
access_log off;
|
|
|
|
}
|
2017-11-07 00:09:01 +01:00
|
|
|
location ~ /\. {
|
|
|
|
deny all;
|
|
|
|
}
|
2018-07-03 17:03:10 +02:00
|
|
|
|
2016-11-09 14:27:00 +01:00
|
|
|
{% if haproxy_ips is defined %}
|
|
|
|
# We are behind haproxy
|
|
|
|
{% for ip in haproxy_ips %}
|
|
|
|
set_real_ip_from {{ ip }};
|
|
|
|
{% endfor %}
|
|
|
|
real_ip_header X-Forwarded-For;
|
|
|
|
{% endif %}
|
2018-07-03 17:03:10 +02:00
|
|
|
|
2016-11-09 14:27:00 +01:00
|
|
|
{% if item.max_body is defined %}
|
|
|
|
client_max_body_size {{ item.max_body }};
|
|
|
|
{% else %}
|
|
|
|
client_max_body_size {{ nginx_client_max_body_size }};
|
|
|
|
{% endif %}
|
|
|
|
{% if item.body_timeout is defined %}
|
|
|
|
client_body_timeout {{ item.body_timeout }};
|
|
|
|
{% else %}
|
|
|
|
client_body_timeout {{ nginx_client_body_timeout }};
|
|
|
|
{% endif %}
|
2018-07-03 17:03:10 +02:00
|
|
|
|
2016-11-09 14:27:00 +01:00
|
|
|
server_tokens {{ item.server_tokens | default('off') }};
|
2016-07-03 12:19:12 +02:00
|
|
|
|
2016-11-09 14:27:00 +01:00
|
|
|
include /etc/nginx/snippets/nginx-server-ssl.conf;
|
|
|
|
|
2018-02-27 14:17:11 +01:00
|
|
|
{% if nginx_cors_enabled %}
|
|
|
|
{% if nginx_cors_global %}
|
|
|
|
include /etc/nginx/snippets/nginx-cors.conf;
|
|
|
|
{% endif %}
|
|
|
|
{% endif %}
|
|
|
|
|
|
|
|
{% if item.additional_options is defined %}
|
|
|
|
{% for add_opt in item.additional_options %}
|
|
|
|
{{ add_opt }};
|
2018-07-03 17:03:10 +02:00
|
|
|
{% endfor %}
|
|
|
|
{% endif %}
|
2018-02-27 14:17:11 +01:00
|
|
|
|
2018-07-03 17:03:10 +02:00
|
|
|
{% if item.https_acls is defined %}
|
|
|
|
{% for acl in item.https_acls %}
|
|
|
|
{{ acl }};
|
2018-02-27 14:17:11 +01:00
|
|
|
{% endfor %}
|
|
|
|
{% endif %}
|
|
|
|
|
2016-11-09 14:27:00 +01:00
|
|
|
{% if item.proxy_standard_setup is defined and item.proxy_standard_setup %}
|
2018-07-03 17:03:10 +02:00
|
|
|
|
2016-07-03 12:19:12 +02:00
|
|
|
# Proxy stuff
|
2017-11-23 17:48:56 +01:00
|
|
|
{% if item.include_global_proxy_conf is defined and not item.include_global_proxy_conf %}
|
|
|
|
{% else %}
|
2016-11-09 14:27:00 +01:00
|
|
|
include /etc/nginx/snippets/nginx-proxy-params.conf;
|
2017-11-23 17:48:56 +01:00
|
|
|
{% endif %}
|
2018-07-03 17:03:10 +02:00
|
|
|
|
2016-11-09 14:27:00 +01:00
|
|
|
{% if item.proxy_additional_options is defined %}
|
|
|
|
{% for popt in item.proxy_additional_options %}
|
|
|
|
{{ popt }}
|
|
|
|
{% endfor %}
|
|
|
|
{% endif %}
|
2018-07-03 17:03:10 +02:00
|
|
|
|
2017-02-01 17:12:54 +01:00
|
|
|
{% if item.locations is defined %}
|
|
|
|
{% for location in item.locations %}
|
|
|
|
location {{ location.location }} {
|
2018-07-03 17:03:10 +02:00
|
|
|
|
2018-02-27 14:17:11 +01:00
|
|
|
{% if nginx_cors_enabled %}
|
|
|
|
{% if not nginx_cors_global %}
|
|
|
|
{% if location.cors is defined and location.cors %}
|
|
|
|
include /etc/nginx/snippets/nginx-cors.conf;
|
|
|
|
{% endif %}
|
|
|
|
{% endif %}
|
|
|
|
{% endif %}
|
2018-07-03 17:03:10 +02:00
|
|
|
|
2017-02-01 17:12:54 +01:00
|
|
|
{% if location.target is defined %}
|
|
|
|
proxy_pass {{ location.target }};
|
|
|
|
{% endif %}
|
2018-07-03 17:03:10 +02:00
|
|
|
|
2018-04-23 17:48:57 +02:00
|
|
|
{% if location.websockets is defined and location.websockets %}
|
|
|
|
proxy_set_header Upgrade $http_upgrade;
|
|
|
|
proxy_set_header Connection "Upgrade";
|
|
|
|
{% endif %}
|
2018-07-03 17:03:10 +02:00
|
|
|
|
2018-02-27 14:17:11 +01:00
|
|
|
{% if location.extra_conf is defined %}
|
|
|
|
{{ location.extra_conf }}
|
|
|
|
{% endif %}
|
2018-07-03 17:03:10 +02:00
|
|
|
|
|
|
|
{% if location.acls is defined %}
|
|
|
|
{% for acl in location.acls %}
|
|
|
|
{{ acl }};
|
|
|
|
{% endfor %}
|
|
|
|
{% endif %}
|
|
|
|
|
|
|
|
{% if location.other_opts is defined %}
|
2017-02-01 17:12:54 +01:00
|
|
|
{% for opt in location.other_opts %}
|
|
|
|
{{ opt }};
|
|
|
|
{% endfor %}
|
|
|
|
{% endif %}
|
2018-07-03 17:03:10 +02:00
|
|
|
}
|
2016-11-09 14:27:00 +01:00
|
|
|
{% endfor %}
|
|
|
|
{% endif %}
|
|
|
|
{% endif %}
|
2018-07-03 17:03:10 +02:00
|
|
|
|
2016-11-09 14:27:00 +01:00
|
|
|
{% if item.extra_parameters is defined %}
|
|
|
|
{{ item.extra_parameters }}
|
2017-02-01 17:12:54 +01:00
|
|
|
{% endif %}
|
2016-07-03 12:19:12 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
{% endif %}
|