xoxys.nginx/templates/etc/nginx/sites-available/vhost.j2

131 lines
4.9 KiB
Plaintext
Raw Normal View History

2019-07-17 21:32:11 +00:00
#jinja2: lstrip_blocks: True
{{ ansible_managed | comment }}
{% if item.upstreams is defined and item.upstreams %}
{% for upstream in item.upstreams %}
2019-07-17 21:32:11 +00:00
upstream {{ upstream.name }} {
{% for upserver in upstream.servers %}
2019-07-17 21:32:11 +00:00
server {{ upserver }};
{% endfor %}
}
{% endfor %}
2019-07-17 21:32:11 +00:00
{% endif %}
{% for server in item.servers %}
2019-07-18 20:51:05 +00:00
2019-07-17 21:32:11 +00:00
server {
2019-07-17 22:16:24 +00:00
listen {{ server.port }}{{ ' ssl' if server.tls is defined and server.tls else '' }};
2019-07-27 11:06:38 +00:00
{% if not server.server_name is string and server.server_name is iterable %}
server_name {{ server.server_name | join(" ") }};
{% else %}
2019-07-17 21:32:11 +00:00
server_name {{ server.server_name }};
2019-07-27 11:06:38 +00:00
{% endif %}
2019-07-17 21:32:11 +00:00
{% if server.tls is defined and server.tls %}
2019-07-18 13:55:52 +00:00
ssl_certificate {{ server.tls.cert }};
ssl_certificate_key {{ server.tls.key }};
2019-07-17 21:32:11 +00:00
{% if server.tls.dhparam is defined %}
ssl_dhparam {{ item.value.ssl.dhparam }};
{% endif %}
{% endif %}
{% if server.tls_redirect | default(False) %}
2019-07-18 14:04:20 +00:00
2019-07-17 21:32:11 +00:00
return 301 https://{% if server.tls_redirect_url is defined %}{{ server.tls_redirect_url }}{% else %}$server_name{% endif %}$request_uri;
{% else %}
{% if server.client_max_body_size is defined and server.client_max_body_size %}
2019-07-27 09:46:44 +00:00
client_max_body_size {{ server.client_max_body_size }};
2019-07-17 21:32:11 +00:00
{% endif %}
2019-08-28 16:32:36 +00:00
{% if server.send_timeout is defined and server.send_timeout %}
send_timeout {{ server.send_timeout }};
2020-05-22 19:22:06 +00:00
{% endif %}
2020-05-25 08:15:42 +00:00
{% if server.custom_options is defined and server.custom_options %}
{% for inline_option in server.custom_options %}
{{ inline_option }}{{ "" if inline_option.startswith("if ") else ";" }}
2020-05-25 08:15:42 +00:00
{% endfor %}
{% endif %}
2019-07-17 21:32:11 +00:00
{% for location in server.locations %}
2019-07-17 22:16:24 +00:00
location {{ location.match }} {
2019-07-17 21:32:11 +00:00
{% if location.root is defined and location.root %}
root {{ location.root }};
{% endif %}
{% if location.index is defined and location.index %}
index {{ location.index }};
2019-07-18 20:51:05 +00:00
2021-05-20 09:00:24 +00:00
{% endif %}
{% if location.add_headers is defined and location.add_headers %}
include /etc/nginx/conf.d/header.conf;
{% for add in location.add_headers %}
add_header {{ add }};
{% endfor %}
2019-07-17 21:32:11 +00:00
{% endif %}
{% if location.proxy_pass is defined and location.proxy_pass %}
2019-07-18 21:55:55 +00:00
proxy_pass {{ location.proxy_pass }};
{% if location.proxy_http_version is defined and location.proxy_http_version %}
proxy_http_version {{ location.proxy_http_version }};
{% endif %}
2019-08-28 16:32:36 +00:00
{% if location.proxy_buffering is defined and location.proxy_buffering %}
proxy_buffering {{ location.proxy_buffering }};
{% endif %}
{% if location.proxy_connect_timeout is defined and location.proxy_connect_timeout %}
proxy_connect_timeout {{ location.proxy_connect_timeout }};
{% endif %}
{% if location.proxy_read_timeout is defined and location.proxy_read_timeout %}
proxy_read_timeout {{ location.proxy_read_timeout }};
{% endif %}
{% if location.proxy_send_timeout is defined and location.proxy_send_timeout %}
proxy_send_timeout {{ location.proxy_send_timeout }};
{% endif %}
2020-05-22 19:40:03 +00:00
{% if location.proxy_intercept_errors is defined and location.proxy_intercept_errors %}
proxy_intercept_errors {{ location.proxy_intercept_errors }};
{% endif %}
2021-05-20 09:00:24 +00:00
{% if location.proxy_set_headers is defined and location.proxy_set_headers %}
{% for set in location.proxy_set_headers %}
proxy_set_header {{ set }};
{% endfor %}
{% endif %}
{% if location.proxy_hide_headers is defined and location.proxy_hide_headers %}
{% for hide in location.proxy_hide_headers %}
proxy_hide_header {{ hide }};
{% endfor %}
{% endif %}
{% if location.proxy_ignore_headers is defined and location.proxy_ignore_headers %}
2019-07-18 21:55:55 +00:00
2021-05-20 09:00:24 +00:00
{% for ignore in location.proxy_ignore_headers %}
proxy_ignore_header {{ ignore }};
2019-07-18 21:55:55 +00:00
{% endfor %}
{% endif %}
2019-07-17 21:32:11 +00:00
{% endif %}
2020-01-18 14:50:29 +00:00
{% if location.custom_options is defined and location.custom_options %}
{% for inline_option in location.custom_options %}
{{ inline_option }}{{ "" if inline_option.startswith("if ") else ";" }}
2020-01-18 14:50:29 +00:00
{% endfor %}
{% endif %}
2019-07-17 21:32:11 +00:00
}
{% endfor %}
2020-05-25 09:22:18 +00:00
{% for error_location in nginx_error_location %}
location {{ error_location.match }} {
{% if error_location.root is defined and error_location.root %}
root {{ error_location.root }};
{% endif %}
2020-05-25 09:22:18 +00:00
{% if error_location.index is defined and error_location.index %}
index {{ error_location.index }};
{% endif %}
2020-05-25 09:22:18 +00:00
{% if error_location.custom_options is defined and error_location.custom_options %}
2020-05-25 09:22:18 +00:00
{% for inline_option in error_location.custom_options %}
{{ inline_option }}{{ "" if inline_option.startswith("if ") else ";" }}
{% endfor %}
{% endif %}
}
2020-05-25 09:22:18 +00:00
{% endfor %}
2020-05-25 09:33:35 +00:00
{% endif %}
2019-07-17 21:32:11 +00:00
}
{% endfor %}