From 4e50ed0fab3dd1c8484ccba98eaa2dbe455df8e3 Mon Sep 17 00:00:00 2001 From: cheggo Date: Mon, 5 Dec 2016 19:10:20 +0100 Subject: [PATCH] added option to disable the defaults directory directive for document roots --- README.md | 4 ++++ defaults/main.yml | 4 ++++ templates/vhosts.conf.j2 | 4 ++-- 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 9e54bf6..9d16a71 100644 --- a/README.md +++ b/README.md @@ -46,6 +46,10 @@ You can add or override global Apache configuration settings in the role-provide Add a set of properties per virtualhost, including `servername` (required), `documentroot` (required), `serveradmin` (optional), `serveralias` (optional) and `extra_parameters` (optional: you can add whatever additional configuration lines you'd like in here). + apache_documentroot_directory_defaults: true + +As the vhost file template automatically sets a default <Directory> directive for your document root, you can disable this by settings this value to `false` and add your own <Directory> directive for your document root via `extra_parameters`. + Here's an example using `extra_parameters` to add a RewriteRule to redirect all requests to the `www.` site: - servername: "www.local.dev" diff --git a/defaults/main.yml b/defaults/main.yml index 4acdfce..15b48c1 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -15,6 +15,10 @@ apache_remove_default_vhost: false apache_global_vhost_settings: | DirectoryIndex index.php index.html +# Create default -Directive +# Set this to `false` for your own -Directive in apache_vhosts.extra_parameters +apache_documentroot_directory_defaults: true + apache_vhosts: # Additional properties: 'serveradmin, serveralias, extra_parameters'. - servername: "local.dev" diff --git a/templates/vhosts.conf.j2 b/templates/vhosts.conf.j2 index 766554f..10a9ef7 100644 --- a/templates/vhosts.conf.j2 +++ b/templates/vhosts.conf.j2 @@ -14,7 +14,7 @@ {% if vhost.serveradmin is defined %} ServerAdmin {{ vhost.serveradmin }} {% endif %} -{% if vhost.documentroot is defined %} +{% if vhost.documentroot is defined and apache_documentroot_directory_defaults %} AllowOverride All Options -Indexes +FollowSymLinks @@ -61,7 +61,7 @@ {% if vhost.serveradmin is defined %} ServerAdmin {{ vhost.serveradmin }} {% endif %} -{% if vhost.documentroot is defined %} +{% if vhost.documentroot is defined and apache_documentroot_directory_defaults %} AllowOverride All Options -Indexes +FollowSymLinks