Skip to content

Commit df84780

Browse files
bigstinky86alessfg
authored andcommitted
Enable autoindex in http, server and location namespaces (#75)
* Added condition to use new autoindex variable * Added condition to use new autoindex variable for separate virtual hosts * Added global autoindex and autoindex for separate virutal hosts * Added autoindex enabling for virtual host namespace * Added autoindex enabling for virtual host namespace variable * Added autoindex for testing puprposes * Changed autoindex to false * Added autoindex for virtual host * Added autoindex ot readme file
1 parent e9a3e6a commit df84780

File tree

5 files changed

+17
-0
lines changed

5 files changed

+17
-0
lines changed

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -312,6 +312,7 @@ nginx_main_template:
312312
rate_limit: false
313313
keyval: false
314314
stream_enable: false
315+
http_global_autoindex: false
315316

316317
# Enable creating dynamic templated NGINX HTTP configuration files.
317318
# Defaults will not produce a valid configuration. Instead they are meant to showcase
@@ -327,6 +328,7 @@ nginx_http_template:
327328
port: 8081
328329
server_name: localhost
329330
error_page: /usr/share/nginx/html
331+
autoindex: false
330332
ssl:
331333
cert: ssl/default.crt
332334
key: ssl/default.key
@@ -336,6 +338,7 @@ nginx_http_template:
336338
location: /
337339
html_file_location: /usr/share/nginx/html
338340
html_file_name: index.html
341+
autoindex: false
339342
http_demo_conf: false
340343
load_balancer:
341344
locations:

defaults/main.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,7 @@ nginx_main_template:
145145
rate_limit: false
146146
keyval: false
147147
stream_enable: false
148+
http_global_autoindex: false
148149

149150
# Enable creating dynamic templated NGINX HTTP configuration files.
150151
# Defaults will not produce a valid configuration. Instead they are meant to showcase
@@ -160,6 +161,7 @@ nginx_http_template:
160161
port: 8081
161162
server_name: localhost
162163
error_page: /usr/share/nginx/html
164+
autoindex: false
163165
ssl:
164166
cert: ssl/default.crt
165167
key: ssl/default.key
@@ -169,6 +171,7 @@ nginx_http_template:
169171
location: /
170172
html_file_location: /usr/share/nginx/html
171173
html_file_name: index.html
174+
autoindex: false
172175
http_demo_conf: false
173176
load_balancer:
174177
locations:

templates/http/default.conf.j2

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@ server {
2323
listen {{ item.value.port }};
2424
{% endif %}
2525
server_name {{ item.value.server_name }};
26+
{% if item.value.autoindex %}
27+
autoindex on;
28+
{% endif %}
2629
{% if item.value.load_balancer is defined %}
2730
{% for location in item.value.load_balancer.locations %}
2831
location {{ item.value.load_balancer.locations[location].location }} {
@@ -43,6 +46,9 @@ server {
4346
location {{ item.value.web_server.locations[location].location }} {
4447
root {{ item.value.web_server.locations[location].html_file_location }};
4548
index {{ item.value.web_server.locations[location].html_file_name }};
49+
{% if item.value.web_server.locations[location].autoindex %}
50+
autoindex on;
51+
{% endif %}
4652
}
4753
{% endfor %}
4854
{% if item.value.web_server.http_demo_conf %}

templates/nginx.conf.j2

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,9 @@ http {
3535
{% if nginx_main_template.http_settings.keyval %}
3636
keyval_zone zone={{nginx_main_template.http_settings.keyval.zone}}:32k state=one.keyval;
3737
keyval $arg_text $text zone=one;
38+
{% endif %}
39+
{% if nginx_main_template.http_global_autoindex %}
40+
autoindex on;
3841
{% endif %}
3942
include /etc/nginx/conf.d/*.conf;
4043
}

tests/playbooks/nginx-template.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,12 @@
1414
port: 80
1515
server_name: localhost
1616
error_page: /usr/share/nginx/html
17+
autoindex: false
1718
web_server:
1819
locations:
1920
default:
2021
location: /
2122
html_file_location: /usr/share/nginx/html
2223
html_file_name: index.html
24+
autoindex: false
2325
http_demo_conf: false

0 commit comments

Comments
 (0)