Skip to content

Commit

Permalink
Enable autoindex in http, server and location namespaces (#75)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
bigstinky86 authored and alessfg committed Nov 26, 2018
1 parent e9a3e6a commit df84780
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 0 deletions.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -312,6 +312,7 @@ nginx_main_template:
rate_limit: false
keyval: false
stream_enable: false
http_global_autoindex: false

# Enable creating dynamic templated NGINX HTTP configuration files.
# Defaults will not produce a valid configuration. Instead they are meant to showcase
Expand All @@ -327,6 +328,7 @@ nginx_http_template:
port: 8081
server_name: localhost
error_page: /usr/share/nginx/html
autoindex: false
ssl:
cert: ssl/default.crt
key: ssl/default.key
Expand All @@ -336,6 +338,7 @@ nginx_http_template:
location: /
html_file_location: /usr/share/nginx/html
html_file_name: index.html
autoindex: false
http_demo_conf: false
load_balancer:
locations:
Expand Down
3 changes: 3 additions & 0 deletions defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,7 @@ nginx_main_template:
rate_limit: false
keyval: false
stream_enable: false
http_global_autoindex: false

# Enable creating dynamic templated NGINX HTTP configuration files.
# Defaults will not produce a valid configuration. Instead they are meant to showcase
Expand All @@ -160,6 +161,7 @@ nginx_http_template:
port: 8081
server_name: localhost
error_page: /usr/share/nginx/html
autoindex: false
ssl:
cert: ssl/default.crt
key: ssl/default.key
Expand All @@ -169,6 +171,7 @@ nginx_http_template:
location: /
html_file_location: /usr/share/nginx/html
html_file_name: index.html
autoindex: false
http_demo_conf: false
load_balancer:
locations:
Expand Down
6 changes: 6 additions & 0 deletions templates/http/default.conf.j2
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ server {
listen {{ item.value.port }};
{% endif %}
server_name {{ item.value.server_name }};
{% if item.value.autoindex %}
autoindex on;
{% endif %}
{% if item.value.load_balancer is defined %}
{% for location in item.value.load_balancer.locations %}
location {{ item.value.load_balancer.locations[location].location }} {
Expand All @@ -43,6 +46,9 @@ server {
location {{ item.value.web_server.locations[location].location }} {
root {{ item.value.web_server.locations[location].html_file_location }};
index {{ item.value.web_server.locations[location].html_file_name }};
{% if item.value.web_server.locations[location].autoindex %}
autoindex on;
{% endif %}
}
{% endfor %}
{% if item.value.web_server.http_demo_conf %}
Expand Down
3 changes: 3 additions & 0 deletions templates/nginx.conf.j2
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ http {
{% if nginx_main_template.http_settings.keyval %}
keyval_zone zone={{nginx_main_template.http_settings.keyval.zone}}:32k state=one.keyval;
keyval $arg_text $text zone=one;
{% endif %}
{% if nginx_main_template.http_global_autoindex %}
autoindex on;
{% endif %}
include /etc/nginx/conf.d/*.conf;
}
Expand Down
2 changes: 2 additions & 0 deletions tests/playbooks/nginx-template.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,12 @@
port: 80
server_name: localhost
error_page: /usr/share/nginx/html
autoindex: false
web_server:
locations:
default:
location: /
html_file_location: /usr/share/nginx/html
html_file_name: index.html
autoindex: false
http_demo_conf: false

0 comments on commit df84780

Please sign in to comment.