Skip to content

Commit 4607756

Browse files
committed
Add better native support for Apache 2.4 when mod_access_compat isn't installed/enabled
1 parent da592f4 commit 4607756

10 files changed

Lines changed: 49 additions & 26 deletions

File tree

manifests/mod/ldap.pp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
1-
class apache::mod::ldap {
1+
class apache::mod::ldap (
2+
$apache_version = $::apache::apache_version,
3+
){
24
::apache::mod { 'ldap': }
3-
# Template uses no variables
5+
# Template uses $apache_version
46
file { 'ldap.conf':
57
ensure => file,
68
path => "${::apache::mod_dir}/ldap.conf",

manifests/mod/pagespeed.pp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
$allow_pagespeed_message = [],
3333
$message_buffer_size = 100000,
3434
$additional_configuration = {},
35+
$apache_version = $::apache::apache_version,
3536
){
3637

3738
$_lib = $::apache::apache_version ? {

manifests/mod/proxy.pp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
class apache::mod::proxy (
22
$proxy_requests = 'Off',
33
$allow_from = undef,
4+
$apache_version = $::apache::apache_version,
45
) {
56
::apache::mod { 'proxy': }
6-
# Template uses $proxy_requests
7+
# Template uses $proxy_requests, $apache_version
78
file { 'proxy.conf':
89
ensure => file,
910
path => "${::apache::mod_dir}/proxy.conf",

manifests/mod/status.pp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,12 @@
2626
class apache::mod::status (
2727
$allow_from = ['127.0.0.1','::1'],
2828
$extended_status = 'On',
29+
$apache_version = $::apache::apache_version,
2930
){
3031
validate_array($allow_from)
3132
validate_re(downcase($extended_status), '^(on|off)$', "${extended_status} is not supported for extended_status. Allowed values are 'On' and 'Off'.")
3233
::apache::mod { 'status': }
33-
# Template uses $allow_from, $extended_status
34+
# Template uses $allow_from, $extended_status, $apache_version
3435
file { 'status.conf':
3536
ensure => file,
3637
path => "${::apache::mod_dir}/status.conf",

manifests/mod/userdir.pp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,11 @@
22
$home = '/home',
33
$dir = 'public_html',
44
$disable_root = true,
5+
$apache_version = $::apache::apache_version,
56
) {
67
::apache::mod { 'userdir': }
78

8-
# Template uses $home, $dir, $disable_root
9+
# Template uses $home, $dir, $disable_root, $apache_version
910
file { 'userdir.conf':
1011
ensure => file,
1112
path => "${::apache::mod_dir}/userdir.conf",

templates/mod/ldap.conf.erb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
11
<Location /ldap-status>
22
SetHandler ldap-status
3+
<%- if scope.function_versioncmp([@apache_version, '2.4']) >= 0 -%>
4+
Require ip 127.0.0.1 ::1
5+
<%- else -%>
36
Order deny,allow
47
Deny from all
58
Allow from 127.0.0.1 ::1
69
Satisfy all
10+
<%- end -%>
711
</Location>

templates/mod/pagespeed.conf.erb

Lines changed: 16 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -54,45 +54,42 @@ ModPagespeedNumExpensiveRewriteThreads <%= @num_expensive_rewrite_threads %>
5454
ModPagespeedStatistics <%= @collect_statistics %>
5555

5656
<Location /mod_pagespeed_statistics>
57-
Order allow,deny
5857
# You may insert other "Allow from" lines to add hosts you want to
5958
# allow to look at generated statistics. Another possibility is
6059
# to comment out the "Order" and "Allow" options from the config
6160
# file, to allow any client that can reach your server to examine
6261
# statistics. This might be appropriate in an experimental setup or
6362
# if the Apache server is protected by a reverse proxy that will
6463
# filter URLs in some fashion.
65-
Allow from localhost
66-
Allow from 127.0.0.1
67-
Allow from ::1
68-
<% @allow_view_stats.each do |host| -%>
69-
Allow from <%= host %>
70-
<% end -%>
64+
<%- if scope.function_versioncmp([@apache_version, '2.4']) >= 0 -%>
65+
Require ip 127.0.0.1 ::1 <%= Array(@allow_view_stats).join(" ") %>
66+
<%- else -%>
67+
Order allow,deny
68+
Allow from 127.0.0.1 ::1 <%= Array(@allow_view_stats).join(" ") %>
69+
<%- end -%>
7170
SetHandler mod_pagespeed_statistics
7271
</Location>
7372

7473
ModPagespeedStatisticsLogging <%= @statistics_logging %>
7574
<Location /pagespeed_console>
75+
<%- if scope.function_versioncmp([@apache_version, '2.4']) >= 0 -%>
76+
Require ip 127.0.0.1 ::1 <%= Array(@allow_pagespeed_console).join(" ") %>
77+
<%- else -%>
7678
Order allow,deny
77-
Allow from localhost
78-
Allow from 127.0.0.1
79-
Allow from ::1
80-
<% @allow_pagespeed_console.each do |host| -%>
81-
Allow from <%= host %>
82-
<% end -%>
79+
Allow from 127.0.0.1 ::1 <%= Array(@allow_pagespeed_console).join(" ") %>
80+
<%- end -%>
8381
SetHandler pagespeed_console
8482
</Location>
8583

8684
ModPagespeedMessageBufferSize <%= @message_buffer_size %>
8785

8886
<Location /mod_pagespeed_message>
87+
<%- if scope.function_versioncmp([@apache_version, '2.4']) >= 0 -%>
88+
Require ip 127.0.0.1 ::1 <%= Array(@allow_pagespeed_message).join(" ") %>
89+
<%- else -%>
8990
Order allow,deny
90-
Allow from localhost
91-
Allow from 127.0.0.1
92-
Allow from ::1
93-
<% @allow_pagespeed_message.each do |host| -%>
94-
Allow from <%= host %>
95-
<% end -%>
91+
Allow from 127.0.0.1 ::1 <%= Array(@allow_pagespeed_message).join(" ") %>
92+
<%- end -%>
9693
SetHandler mod_pagespeed_message
9794
</Location>
9895

templates/mod/proxy.conf.erb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,13 @@
1010

1111
<% if @proxy_requests != 'Off' or ( @allow_from and ! @allow_from.empty? ) -%>
1212
<Proxy *>
13+
<%- if scope.function_versioncmp([@apache_version, '2.4']) >= 0 -%>
14+
Require ip <%= Array(@allow_from).join(" ") %>
15+
<%- else -%>
1316
Order deny,allow
1417
Deny from all
1518
Allow from <%= Array(@allow_from).join(" ") %>
19+
<%- end -%>
1620
</Proxy>
1721
<% end -%>
1822

templates/mod/status.conf.erb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,12 @@
11
<Location /server-status>
22
SetHandler server-status
3+
<%- if scope.function_versioncmp([@apache_version, '2.4']) >= 0 -%>
4+
Require ip <%= Array(@allow_from).join(" ") %>
5+
<%- else -%>
36
Order deny,allow
47
Deny from all
58
Allow from <%= Array(@allow_from).join(" ") %>
9+
<%- end -%>
610
</Location>
711
ExtendedStatus <%= @extended_status %>
812

templates/mod/userdir.conf.erb

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,20 @@
88
AllowOverride FileInfo AuthConfig Limit Indexes
99
Options MultiViews Indexes SymLinksIfOwnerMatch IncludesNoExec
1010
<Limit GET POST OPTIONS>
11+
<%- if scope.function_versioncmp([@apache_version, '2.4']) >= 0 -%>
12+
Require all denied
13+
<%- else -%>
1114
Order allow,deny
1215
Allow from all
16+
<%- end -%>
1317
</Limit>
1418
<LimitExcept GET POST OPTIONS>
15-
Order deny,allow
16-
Deny from all
19+
<%- if scope.function_versioncmp([@apache_version, '2.4']) >= 0 -%>
20+
Require all denied
21+
<%- else -%>
22+
Order allow,deny
23+
Allow from all
24+
<%- end -%>
1725
</LimitExcept>
1826
</Directory>
1927
</IfModule>

0 commit comments

Comments
 (0)