diff --git a/defaults/main.yml b/defaults/main.yml index a059b3b..64d43de 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -171,6 +171,7 @@ nginx_http_template: root: /usr/share/nginx/html https_redirect: false autoindex: false + try_files: $uri $uri/index.html $uri.html =404 ssl: cert: /etc/ssl/certs/default.crt key: /etc/ssl/private/default.key @@ -187,6 +188,7 @@ nginx_http_template: autoindex: false auth_basic: null auth_basic_file: null + try_files: $uri $uri/index.html $uri.html =404 http_demo_conf: false reverse_proxy: proxy_cache_path: @@ -238,6 +240,7 @@ nginx_http_template: websocket: false auth_basic: null auth_basic_file: null + try_files: $uri $uri/index.html $uri.html =404 health_check_plus: false proxy_cache: proxy_cache_path: diff --git a/templates/http/default.conf.j2 b/templates/http/default.conf.j2 index 45a9cb2..c0e2120 100644 --- a/templates/http/default.conf.j2 +++ b/templates/http/default.conf.j2 @@ -77,6 +77,9 @@ server { {% if item.value.autoindex is defined and item.value.autoindex %} autoindex on; {% endif %} +{% if item.value.try_files is defined %} + try_files {{ item.value.try_files }}; +{% endif %} {% if item.value.reverse_proxy is defined %} {% for location in item.value.reverse_proxy.locations %} location {{ item.value.reverse_proxy.locations[location].location }} { @@ -93,6 +96,9 @@ server { {% if item.value.reverse_proxy.locations[location].proxy_read_timeout is defined and item.value.reverse_proxy.locations[location].proxy_read_timeout %} proxy_read_timeout {{ item.value.reverse_proxy.locations[location].proxy_read_timeout }}; {% endif %} +{% if item.value.reverse_proxy.locations[location].try_files is defined %} + try_files {{ item.value.reverse_proxy.locations[location].try_files }}; +{% endif %} {% if item.value.reverse_proxy.locations[location].proxy_ssl is defined %} {% if item.value.reverse_proxy.locations[location].proxy_ssl.cert is defined %} @@ -177,6 +183,9 @@ server { {% if item.value.web_server.locations[location].autoindex %} autoindex on; {% endif %} +{% if item.value.web_server.locations[location].try_files is defined %} + try_files {{ item.value.web_server.locations[location].try_files }}; +{% endif %} {% if item.value.web_server.locations[location].auth_basic is defined and item.value.web_server.locations[location].auth_basic %} auth_basic "{{ item.value.web_server.locations[location].auth_basic }}"; {% endif %} diff --git a/templates/stream/default.conf.j2 b/templates/stream/default.conf.j2 index ab2d5b0..38090b9 100644 --- a/templates/stream/default.conf.j2 +++ b/templates/stream/default.conf.j2 @@ -22,11 +22,19 @@ upstream {{ item.value.upstreams[upstream].name }} { {% for stream in item.value.network_streams %} server { {% if item.value.network_streams[stream].listen_address is defined and item.value.network_streams[stream].listen_port is defined %} +{% if item.value.network_streams[stream].listen_address == 'localhost' %} +{% if item.value.network_streams[stream].udp_enable %} + listen {{ item.value.network_streams[stream].listen_port }} udp; +{% else %} + listen {{ item.value.network_streams[stream].listen_port }}; +{% endif %} +{% else %} {% if item.value.network_streams[stream].udp_enable %} listen {{ item.value.network_streams[stream].listen_address }}:{{ item.value.network_streams[stream].listen_port }} udp; {% else %} listen {{ item.value.network_streams[stream].listen_address }}:{{ item.value.network_streams[stream].listen_port }}; {% endif %} +{% endif %} {% elif item.value.network_streams[stream].listen_port is defined %} {% if item.value.network_streams[stream].udp_enable %} listen {{ item.value.network_streams[stream].listen_port }} udp;