Skip to content

Allow setting KeepAlive related options per vhost #1447

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 7, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 19 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2206,6 +2206,24 @@ apache::vhost { 'sample.example.net':
}
```

##### `keepalive`

Determines whether to enable persistent HTTP connections with the [`KeepAlive`][] directive for the virtual host. Valid options: 'Off', 'On' and `undef`. Default: `undef`, meaning the global, server-wide [`KeepAlive`][] setting is in effect.

Use the `keepalive_timeout` and `max_keepalive_requests` parameters to set relevant options for the virtual host.

##### `keepalive_timeout`

Sets the [`KeepAliveTimeout`] directive for the virtual host, which determines the amount of time to wait for subsequent requests on a persistent HTTP connection. Default: `undef`, meaning the global, server-wide [`KeepAlive`][] setting is in effect.

This parameter is only relevant if either the global, server-wide [`keepalive` parameter][] or the per-vhost `keepalive` parameter is enabled.

##### `max_keepalive_requests`

Limits the number of requests allowed per connection to the virtual host. Default: `undef`, meaning the global, server-wide [`KeepAlive`][] setting is in effect.

This parameter is only relevant if either the global, server-wide [`keepalive` parameter][] or the per-vhost `keepalive` parameter is enabled.

##### `auth_kerb`

Enable [`mod_auth_kerb`][] parameters for a virtual host. Valid options: Boolean. Default: false.
Expand Down Expand Up @@ -3192,7 +3210,7 @@ apache::vhost { 'sample.example.net':
docroot => '/path/to/directory',
directories => [
{ path => '/path/to/directory',
require => {
require => {
enforce => 'all',
require => ['group', 'not host host.example.com'],
},
Expand Down
19 changes: 19 additions & 0 deletions manifests/vhost.pp
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,9 @@
$krb_verify_kdc = 'on',
$krb_servicename = 'HTTP',
$krb_save_credentials = 'off',
$keepalive = undef,
$keepalive_timeout = undef,
$max_keepalive_requests = undef,
) {
# The base class must be included first because it is used by parameter defaults
if ! defined(Class['apache']) {
Expand Down Expand Up @@ -264,6 +267,10 @@
validate_re($ssl_proxy_check_peer_expire,'(^on$|^off$)',"${ssl_proxy_check_peer_expire} is not permitted for ssl_proxy_check_peer_expire. Allowed values are 'on' or 'off'.")
}

if $keepalive {
validate_re($keepalive,'(^on$|^off$)',"${keepalive} is not permitted for keepalive. Allowed values are 'on' or 'off'.")
}

# Input validation ends

if $ssl and $ensure == 'present' {
Expand Down Expand Up @@ -1051,6 +1058,18 @@
}
}

# Template uses:
# - $keepalive
# - $keepalive_timeout
# - $max_keepalive_requests
if $keepalive or $keepalive_timeout or $max_keepalive_requests {
concat::fragment { "${name}-keepalive_options":
target => "${priority_real}${filename}.conf",
order => 350,
content => template('apache/vhost/_keepalive_options.erb'),
}
}

# Template uses no variables
concat::fragment { "${name}-file_footer":
target => "${priority_real}${filename}.conf",
Expand Down
17 changes: 13 additions & 4 deletions spec/defines/vhost_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@
'path' => '/var/www/files',
'provider' => 'files',
'require' =>
{
{
'enforce' => 'all',
'requires' => ['all-valid1', 'all-valid2'],
},
Expand All @@ -210,7 +210,7 @@
'path' => '/var/www/files',
'provider' => 'files',
'require' =>
{
{
'enforce' => 'none',
'requires' => ['none-valid1', 'none-valid2'],
},
Expand All @@ -219,7 +219,7 @@
'path' => '/var/www/files',
'provider' => 'files',
'require' =>
{
{
'enforce' => 'any',
'requires' => ['any-valid1', 'any-valid2'],
},
Expand Down Expand Up @@ -395,7 +395,10 @@
'krb_authoritative' => 'off',
'krb_auth_realms' => ['EXAMPLE.ORG','EXAMPLE.NET'],
'krb_5keytab' => '/tmp/keytab5',
'krb_local_user_mapping' => 'off'
'krb_local_user_mapping' => 'off',
'keepalive' => 'on',
'keepalive_timeout' => '100',
'max_keepalive_requests' => '1000',
}
end
let :facts do
Expand Down Expand Up @@ -600,6 +603,12 @@
:content => /^\s+KrbSaveCredentials\soff$/)}
it { is_expected.to contain_concat__fragment('rspec.example.com-auth_kerb').with(
:content => /^\s+KrbVerifyKDC\son$/)}
it { is_expected.to contain_concat__fragment('rspec.example.com-keepalive_options').with(
:content => /^\s+KeepAlive\son$/)}
it { is_expected.to contain_concat__fragment('rspec.example.com-keepalive_options').with(
:content => /^\s+KeepAliveTimeout\s100$/)}
it { is_expected.to contain_concat__fragment('rspec.example.com-keepalive_options').with(
:content => /^\s+MaxKeepAliveRequests\s1000$/)}
end
context 'vhost with multiple ip addresses' do
let :params do
Expand Down
9 changes: 9 additions & 0 deletions templates/vhost/_keepalive_options.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<%- if @keepalive -%>
KeepAlive <%= @keepalive %>
<%- end -%>
<%- if @keepalive_timeout -%>
KeepAliveTimeout <%= @keepalive_timeout %>
<%- end -%>
<%- if @max_keepalive_requests -%>
MaxKeepAliveRequests <%= @max_keepalive_requests %>
<%- end -%>