Skip to content

Commit

Permalink
Merge pull request #1228 from wickedOne/rewritelock
Browse files Browse the repository at this point in the history
RewriteLock support
  • Loading branch information
igalic committed Oct 19, 2015
2 parents 9c1047d + d38cc4d commit f515778
Show file tree
Hide file tree
Showing 4 changed files with 52 additions and 5 deletions.
8 changes: 7 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -1065,6 +1065,12 @@ If the [`vhost_dir`][] parameter's value differs from the [`confd_dir`][] parame

Setting `purge_vhost_dir` to 'false' is a stopgap measure to allow the apache Puppet module to coexist with existing or otherwise unmanaged configurations within `vhost_dir`.

##### `rewrite_lock`

Allows setting a custom location for a rewrite lock - considered best practice if using a RewriteMap of type prg in the [`rewrites`][] parameter of your vhost. Default: 'undef'.

This parameter only applies to Apache version 2.2 or lower and is ignored on newer versions.

##### `sendfile`

Forces Apache to use the Linux kernel's `sendfile` support to serve static files, via the [`EnableSendfile`][] directive. Valid options: 'On', 'Off'. Default: 'On'.
Expand Down Expand Up @@ -2023,7 +2029,7 @@ Usage typically looks like:
krb_method_negotiate => 'on',
krb_auth_realms => ['EXAMPLE.ORG'],
krb_local_user_mapping => 'on',
directories => {
directories => {
path => '/var/www/html',
auth_name => 'Kerberos Login',
auth_type => 'Kerberos',
Expand Down
6 changes: 6 additions & 0 deletions manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@
$conf_template = $::apache::params::conf_template,
$servername = $::apache::params::servername,
$pidfile = $::apache::params::pidfile,
$rewrite_lock = undef,
$manage_user = true,
$manage_group = true,
$user = $::apache::params::user,
Expand Down Expand Up @@ -296,6 +297,10 @@
default => false
}

if $rewrite_lock {
validate_absolute_path($rewrite_lock)
}

# Template uses:
# - $pidfile
# - $user
Expand All @@ -317,6 +322,7 @@
# - $server_tokens
# - $server_signature
# - $trace_enable
# - $rewrite_lock
file { "${::apache::conf_dir}/${::apache::params::conf_file}":
ensure => file,
content => template($conf_template),
Expand Down
39 changes: 35 additions & 4 deletions spec/classes/apache_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -156,23 +156,23 @@
:apache_version => '2.2',
}
end

context "when default_type => 'none'" do
let :params do
{ :default_type => 'none' }
end

it { is_expected.to contain_file("/etc/apache2/apache2.conf").with_content %r{^DefaultType none$} }
end
context "when default_type => 'text/plain'" do
let :params do
{ :default_type => 'text/plain' }
end

it { is_expected.to contain_file("/etc/apache2/apache2.conf").with_content %r{^DefaultType text/plain$} }
end
end

context "with Apache version >= 2.4" do
let :params do
{
Expand Down Expand Up @@ -388,6 +388,37 @@
it { is_expected.to contain_file("/etc/httpd/conf/httpd.conf").with_content %r{^IncludeOptional "/etc/httpd/conf\.d/\*\.conf"$} }
end

context "with Apache version < 2.4" do
let :params do
{
:apache_version => '2.2',
:rewrite_lock => '/var/lock/subsys/rewrite-lock'
}
end

it { is_expected.to contain_file("/etc/httpd/conf/httpd.conf").with_content %r{^RewriteLock /var/lock/subsys/rewrite-lock$} }
end

context "with Apache version < 2.4" do
let :params do
{
:apache_version => '2.2'
}
end

it { is_expected.to contain_file("/etc/httpd/conf/httpd.conf").without_content %r{^RewriteLock [.]*$} }
end

context "with Apache version >= 2.4" do
let :params do
{
:apache_version => '2.4',
:rewrite_lock => '/var/lock/subsys/rewrite-lock'
}
end
it { is_expected.to contain_file("/etc/httpd/conf/httpd.conf").without_content %r{^RewriteLock [.]*$} }
end

context "when specifying slash encoding behaviour" do
let :params do
{ :allow_encoded_slashes => 'nodecode' }
Expand Down
4 changes: 4 additions & 0 deletions templates/httpd.conf.erb
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ KeepAlive <%= @keepalive %>
MaxKeepAliveRequests <%= @max_keepalive_requests %>
KeepAliveTimeout <%= @keepalive_timeout %>

<%- if @rewrite_lock and scope.function_versioncmp([@apache_version, '2.2']) <= 0 -%>
RewriteLock <%= @rewrite_lock %>
<%- end -%>

User <%= @user %>
Group <%= @group %>

Expand Down

0 comments on commit f515778

Please sign in to comment.