-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #471 from ptomulik/mod_rpaf_support
Mod rpaf support (with FreeBSD support)
- Loading branch information
Showing
6 changed files
with
118 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
class apache::mod::rpaf ( | ||
$sethostname = true, | ||
$proxy_ips = [ '127.0.0.1' ], | ||
$header = 'X-Forwarded-For' | ||
) { | ||
apache::mod { 'rpaf': } | ||
|
||
# Template uses: | ||
# - $sethostname | ||
# - $proxy_ips | ||
# - $header | ||
file { 'rpaf.conf': | ||
ensure => file, | ||
path => "${apache::mod_dir}/rpaf.conf", | ||
content => template('apache/mod/rpaf.conf.erb'), | ||
require => Exec["mkdir ${apache::mod_dir}"], | ||
before => File[$apache::mod_dir], | ||
notify => Service['httpd'], | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
describe 'apache::mod::rpaf', :type => :class do | ||
let :pre_condition do | ||
[ | ||
'include apache', | ||
] | ||
end | ||
context "on a Debian OS" do | ||
let :facts do | ||
{ | ||
:osfamily => 'Debian', | ||
:operatingsystemrelease => '6', | ||
:concat_basedir => '/dne', | ||
} | ||
end | ||
it { should include_class("apache::params") } | ||
it { should contain_apache__mod('rpaf') } | ||
it { should contain_package("libapache2-mod-rpaf") } | ||
it { should contain_file('rpaf.conf').with({ | ||
'path' => '/etc/apache2/mods-available/rpaf.conf', | ||
}) } | ||
it { should contain_file('rpaf.conf').with_content(/^RPAFenable On$/) } | ||
|
||
describe "with sethostname => true" do | ||
let :params do | ||
{ :sethostname => 'true' } | ||
end | ||
it { should contain_file('rpaf.conf').with_content(/^RPAFsethostname On$/) } | ||
end | ||
describe "with proxy_ips => [ 10.42.17.8, 10.42.18.99 ]" do | ||
let :params do | ||
{ :proxy_ips => [ '10.42.17.8', '10.42.18.99' ] } | ||
end | ||
it { should contain_file('rpaf.conf').with_content(/^RPAFproxy_ips 10.42.17.8 10.42.18.99$/) } | ||
end | ||
describe "with header => X-Real-IP" do | ||
let :params do | ||
{ :header => 'X-Real-IP' } | ||
end | ||
it { should contain_file('rpaf.conf').with_content(/^RPAFheader X-Real-IP$/) } | ||
end | ||
end | ||
context "on a FreeBSD OS" do | ||
let :facts do | ||
{ | ||
:osfamily => 'FreeBSD', | ||
:operatingsystemrelease => '9', | ||
:concat_basedir => '/dne', | ||
} | ||
end | ||
it { should include_class("apache::params") } | ||
it { should contain_apache__mod('rpaf') } | ||
it { should contain_package("www/mod_rpaf2") } | ||
it { should contain_file('rpaf.conf').with({ | ||
'path' => '/usr/local/etc/apache22/Modules/rpaf.conf', | ||
}) } | ||
it { should contain_file('rpaf.conf').with_content(/^RPAFenable On$/) } | ||
|
||
describe "with sethostname => true" do | ||
let :params do | ||
{ :sethostname => 'true' } | ||
end | ||
it { should contain_file('rpaf.conf').with_content(/^RPAFsethostname On$/) } | ||
end | ||
describe "with proxy_ips => [ 10.42.17.8, 10.42.18.99 ]" do | ||
let :params do | ||
{ :proxy_ips => [ '10.42.17.8', '10.42.18.99' ] } | ||
end | ||
it { should contain_file('rpaf.conf').with_content(/^RPAFproxy_ips 10.42.17.8 10.42.18.99$/) } | ||
end | ||
describe "with header => X-Real-IP" do | ||
let :params do | ||
{ :header => 'X-Real-IP' } | ||
end | ||
it { should contain_file('rpaf.conf').with_content(/^RPAFheader X-Real-IP$/) } | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
# Enable reverse proxy add forward | ||
RPAFenable On | ||
# RPAFsethostname will, when enabled, take the incoming X-Host header and | ||
# update the virtual host settings accordingly. This allows to have the same | ||
# hostnames as in the "real" configuration for the forwarding proxy. | ||
<% if @sethostname -%> | ||
RPAFsethostname On | ||
<% else -%> | ||
RPAFsethostname Off | ||
<% end -%> | ||
# Which IPs are forwarding requests to us | ||
RPAFproxy_ips <%= Array(@proxy_ips).join(" ") %> | ||
# Setting RPAFheader allows you to change the header name to parse from the | ||
# default X-Forwarded-For to something of your choice. | ||
RPAFheader <%= @header %> |