Skip to content

Commit 4c96e19

Browse files
magicalyakgdzien
authored andcommitted
Added support for try_files (#117)
* Added support for try_files * updated try_files for server and web server * change stream test template port to 81 for travis * Fix for travis test and localhost error
1 parent 1cf74a5 commit 4c96e19

File tree

3 files changed

+20
-0
lines changed

3 files changed

+20
-0
lines changed

defaults/main.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,7 @@ nginx_http_template:
171171
root: /usr/share/nginx/html
172172
https_redirect: false
173173
autoindex: false
174+
try_files: $uri $uri/index.html $uri.html =404
174175
ssl:
175176
cert: /etc/ssl/certs/default.crt
176177
key: /etc/ssl/private/default.key
@@ -187,6 +188,7 @@ nginx_http_template:
187188
autoindex: false
188189
auth_basic: null
189190
auth_basic_file: null
191+
try_files: $uri $uri/index.html $uri.html =404
190192
http_demo_conf: false
191193
reverse_proxy:
192194
proxy_cache_path:
@@ -238,6 +240,7 @@ nginx_http_template:
238240
websocket: false
239241
auth_basic: null
240242
auth_basic_file: null
243+
try_files: $uri $uri/index.html $uri.html =404
241244
health_check_plus: false
242245
proxy_cache:
243246
proxy_cache_path:

templates/http/default.conf.j2

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,9 @@ server {
7777
{% if item.value.autoindex is defined and item.value.autoindex %}
7878
autoindex on;
7979
{% endif %}
80+
{% if item.value.try_files is defined %}
81+
try_files {{ item.value.try_files }};
82+
{% endif %}
8083
{% if item.value.reverse_proxy is defined %}
8184
{% for location in item.value.reverse_proxy.locations %}
8285
location {{ item.value.reverse_proxy.locations[location].location }} {
@@ -93,6 +96,9 @@ server {
9396
{% if item.value.reverse_proxy.locations[location].proxy_read_timeout is defined and item.value.reverse_proxy.locations[location].proxy_read_timeout %}
9497
proxy_read_timeout {{ item.value.reverse_proxy.locations[location].proxy_read_timeout }};
9598
{% endif %}
99+
{% if item.value.reverse_proxy.locations[location].try_files is defined %}
100+
try_files {{ item.value.reverse_proxy.locations[location].try_files }};
101+
{% endif %}
96102
{% if item.value.reverse_proxy.locations[location].proxy_ssl is defined %}
97103

98104
{% if item.value.reverse_proxy.locations[location].proxy_ssl.cert is defined %}
@@ -177,6 +183,9 @@ server {
177183
{% if item.value.web_server.locations[location].autoindex %}
178184
autoindex on;
179185
{% endif %}
186+
{% if item.value.web_server.locations[location].try_files is defined %}
187+
try_files {{ item.value.web_server.locations[location].try_files }};
188+
{% endif %}
180189
{% if item.value.web_server.locations[location].auth_basic is defined and item.value.web_server.locations[location].auth_basic %}
181190
auth_basic "{{ item.value.web_server.locations[location].auth_basic }}";
182191
{% endif %}

templates/stream/default.conf.j2

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,19 @@ upstream {{ item.value.upstreams[upstream].name }} {
2222
{% for stream in item.value.network_streams %}
2323
server {
2424
{% if item.value.network_streams[stream].listen_address is defined and item.value.network_streams[stream].listen_port is defined %}
25+
{% if item.value.network_streams[stream].listen_address == 'localhost' %}
26+
{% if item.value.network_streams[stream].udp_enable %}
27+
listen {{ item.value.network_streams[stream].listen_port }} udp;
28+
{% else %}
29+
listen {{ item.value.network_streams[stream].listen_port }};
30+
{% endif %}
31+
{% else %}
2532
{% if item.value.network_streams[stream].udp_enable %}
2633
listen {{ item.value.network_streams[stream].listen_address }}:{{ item.value.network_streams[stream].listen_port }} udp;
2734
{% else %}
2835
listen {{ item.value.network_streams[stream].listen_address }}:{{ item.value.network_streams[stream].listen_port }};
2936
{% endif %}
37+
{% endif %}
3038
{% elif item.value.network_streams[stream].listen_port is defined %}
3139
{% if item.value.network_streams[stream].udp_enable %}
3240
listen {{ item.value.network_streams[stream].listen_port }} udp;

0 commit comments

Comments
 (0)