apache: Added support for forward proxy with optional caching
This commit is contained in:
parent
9d2c3104e2
commit
341c86a0a0
2 changed files with 82 additions and 18 deletions
|
@ -385,6 +385,67 @@ define apache::configfile($source="", $content="", $http=true, $https=true) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
# Configure forward proxy.
|
||||||
|
#
|
||||||
|
# === Parameters
|
||||||
|
#
|
||||||
|
# $port:
|
||||||
|
# Port to listen. Defaults to "8080".
|
||||||
|
# $allow:
|
||||||
|
# Array of addresses or networks allowed to connect.
|
||||||
|
# Defaults to ["127.0.0.1"].
|
||||||
|
# $cache:
|
||||||
|
# Enable disk cache. Defaults to false.
|
||||||
|
# $cachesize:
|
||||||
|
# Maximum size of the cache. Defaults to "1024M".
|
||||||
|
# $cachecleantime:
|
||||||
|
# Cache cleaning interval in minutes.
|
||||||
|
# Defaults to "60".
|
||||||
|
#
|
||||||
|
class apache::proxy($port="8080",
|
||||||
|
$allow=["127.0.0.1"],
|
||||||
|
$cache=false,
|
||||||
|
$cachesize="1024M",
|
||||||
|
$cachecleantime="60") {
|
||||||
|
|
||||||
|
include apache::mod::proxy
|
||||||
|
|
||||||
|
if $cache == true {
|
||||||
|
case $::operatingsystem {
|
||||||
|
"centos","redhat","fedora": {
|
||||||
|
$cachepath = "/var/cache/mod_proxy"
|
||||||
|
|
||||||
|
augeas { "set-htcacheclean-sysconfig":
|
||||||
|
changes => [
|
||||||
|
"set INTERVAL ${cachecleantime}",
|
||||||
|
"set CACHE_ROOT ${cachepath}",
|
||||||
|
"set CACHE_LIMIT ${cachesize}",
|
||||||
|
],
|
||||||
|
incl => "/etc/sysconfig/htcacheclean",
|
||||||
|
lens => "Shellvars.lns",
|
||||||
|
require => Package["httpd"],
|
||||||
|
notify => Service["htcacheclean"],
|
||||||
|
}
|
||||||
|
|
||||||
|
service { "htcacheclean":
|
||||||
|
ensure => running,
|
||||||
|
enable => true,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
default: {
|
||||||
|
fail("Caching proxy not supported in ${::operatingsystem}")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
apache::configfile { "proxy.conf":
|
||||||
|
https => false,
|
||||||
|
content => template("apache/proxy.conf.erb"),
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
# Install mod_auth_kerb.
|
# Install mod_auth_kerb.
|
||||||
#
|
#
|
||||||
class apache::mod::auth_kerb {
|
class apache::mod::auth_kerb {
|
||||||
|
@ -683,15 +744,9 @@ class apache::mod::proxy {
|
||||||
|
|
||||||
case $::operatingsystem {
|
case $::operatingsystem {
|
||||||
"debian","ubuntu": {
|
"debian","ubuntu": {
|
||||||
apache::debian::a2enmod { "proxy":
|
apache::debian::a2enmod { "proxy": }
|
||||||
content => template("apache/proxy.conf.erb"),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
"centos","redhat","fedora": {
|
|
||||||
apache::configfile { "proxy.conf":
|
|
||||||
content => template("apache/proxy.conf.erb"),
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
"centos","redhat","fedora": { }
|
||||||
default: {
|
default: {
|
||||||
fail("Apache module not supported in ${::operatingsystem}.")
|
fail("Apache module not supported in ${::operatingsystem}.")
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,12 +1,21 @@
|
||||||
<% if @apache_proxy_allow -%>
|
Listen <%= @port %>
|
||||||
|
|
||||||
|
<VirtualHost _default_:<%= @port %>>
|
||||||
ProxyRequests On
|
ProxyRequests On
|
||||||
ProxyVia On
|
ProxyVia On
|
||||||
|
|
||||||
|
<% if @cache == true -%>
|
||||||
|
<IfModule mod_disk_cache.c>
|
||||||
|
CacheEnable disk /
|
||||||
|
CacheRoot <%= @cachepath %>
|
||||||
|
</IfModule>
|
||||||
|
|
||||||
|
<% end -%>
|
||||||
<Proxy *>
|
<Proxy *>
|
||||||
Order deny,allow
|
Order deny,allow
|
||||||
Deny from all
|
Deny from all
|
||||||
Allow from <%= @apache_proxy_allow %>
|
<% @allow.each do |addr| -%>
|
||||||
</Proxy>
|
Allow from <%= addr %>
|
||||||
<% else -%>
|
|
||||||
ProxyRequests Off
|
|
||||||
<% end -%>
|
<% end -%>
|
||||||
|
</Proxy>
|
||||||
|
</VirtualHost>
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue