ansible-nginx/templates/etc/nginx/sites-available/COMMON.j2

33 lines
1.1 KiB
Plaintext
Raw Normal View History

2015-07-15 22:57:42 +07:00
{% set server_name = [ item.name ] %}
{% set aliases = item.aliases if item.aliases is defined else [] %}
{% set ignore = server_name.extend(aliases) %}
2015-07-15 20:18:51 +07:00
{% if item.ssl is defined and item.ssl.use is defined and item.ssl.use %}
listen {{ item.listen | default('443') }};
2015-07-15 22:57:42 +07:00
server_name {{ server_name | join(' ') }};
2015-07-15 20:18:51 +07:00
ssl on;
ssl_certificate {{ nginx_ssl_dir }}/{{ item.name }}/{{ item.name }}.crt;
ssl_certificate_key {{ nginx_ssl_dir }}/{{ item.name }}/{{ item.name }}.key;
include /etc/nginx/helpers/ssl-{{ item.ssl.template | default('strong') }};
{% else %}
listen {{ item.listen | default('80') }};
2015-07-15 22:57:42 +07:00
server_name {{ server_name | join(' ') }};
2015-07-15 20:18:51 +07:00
{% endif %}
2015-07-16 16:44:54 +07:00
{% if item.root is defined %}
root {{ item.root }};
{% else %}
2015-07-15 20:18:51 +07:00
root {{ nginx_root }}/{{ item.name }}/public;
2015-07-16 16:44:54 +07:00
{% endif %}
2015-07-15 20:18:51 +07:00
{% if item.use_access_log is defined and item.use_access_log %}
access_log {{ nginx_log_dir }}/{{ item.name }}_access.log combined;
{% else %}
access_log off;
{% endif %}
{% if item.use_error_log is defined and item.use_error_log %}
error_log {{ nginx_log_dir }}/{{ item.name }}_error.log {{ nginx_error_log_level }};
{% else %}
error_log off;
{% endif %}