123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141#
# !!! This file is managed by Ansible !!!
#
{% if services.nginx.sslOnly is not defined or services.nginx.sslOnly is false %}
server {
{% if item.value.defaultServer is defined and item.value.defaultServer is true%}
listen 80 default_server;
listen [::]:80 default_server;
{% else %}
listen 80;
listen [::]:80;
{% endif %}
server_name {{item.key}};
{% if item.value.root is defined %}
root {{ item.value.root }};
{% endif %}
{% if item.value.index is defined %}
index {{ item.value.index }};
{% else %}
{% if item.value.enablePhpSupport is true %}
index index.php index.html;
{% endif %}
{% endif %}
{% if item.value.locations is defined %}
{% for location in item.value.locations %}
location {{ location.path }} {
{% if location.proxy is defined %}
proxy_pass {{ location.proxy }};
include /etc/nginx/proxy.conf;
{% endif %}
{% if location.root is defined %}
root {{ location.root }};
{% endif %}
{% if location.directoryListing is true %}
autoindex on;
autoindex_exact_size off;
{% endif %}
{% if location.basicAuth is defined %}
auth_basic "{{ location.basicAuthReason | default('Authorization required') }}";
auth_basic_user_file {{ location.basicAuth }};
{% endif %}
{% if location.extraConfig is defined %}
{{ location.extraConfig }}
{% endif %}
}
{% endfor %}
{% endif %}
{% if item.value.enablePhpSupport is true %}
location ~ \.php$ {
fastcgi_pass unix:{{ item.value.phpSocket | default("/run/php-fpm/php-fpm.sock") }};
fastcgi_index index.php;
include php_fastcgi_params;
}
{% endif %}
{% if item.value.extraConfig is defined %}
{{ item.value.extraConfig }}
{% endif %}
}
{% endif %}
{% if item.value.ssl.enable is defined and item.value.ssl.enable is true %}
server {
{% if item.value.defaultServer is defined and item.value.defaultServer is true%}
listen 443 ssl default_server;
listen [::]:443 ssl default_server;
{% else %}
listen 443 ssl;
listen [::]:443 ssl;
{% endif %}
server_name {{item.key}};
ssl_certificate "{{ item.value.ssl.cert }}";
ssl_certificate_key "{{ item.value.ssl.privkey }}";
include /etc/nginx/ssl.conf;
{% if item.value.root is defined %}
root {{ item.value.root }};
{% endif %}
{% if item.value.index is defined %}
index {{ item.value.index }};
{% else %}
{% if item.value.enablePhpSupport is true %}
index index.php index.html;
{% endif %}
{% endif %}
{% if item.value.locations is defined %}
{% for location in item.value.locations %}
location {{ location.path }} {
{% if location.proxy is defined %}
proxy_pass {{ location.proxy }};
include /etc/nginx/proxy.conf;
{% endif %}
{% if location.root is defined %}
root {{ location.root }};
{% endif %}
{% if location.directoryListing is true %}
autoindex on;
autoindex_exact_size off;
{% endif %}
{% if location.basicAuth is defined %}
auth_basic "{{ location.basicAuthReason | default('Authorization required') }}";
auth_basic_user_file {{ location.basicAuth }};
{% endif %}
{% if location.extraConfig is defined %}
{{ location.extraConfig }}
{% endif %}
}
{% endfor %}
{% endif %}
{% if item.value.enablePhpSupport is true %}
location ~ \.php$ {
fastcgi_pass unix:{{ item.value.phpSocket | default("/run/php-fpm/php-fpm.sock") }};
fastcgi_index index.php;
include php_fastcgi_params;
}
{% endif %}
{% if item.value.extraConfig is defined %}
{{ item.value.extraConfig }}
{% endif %}
}
{% endif %}