apache: Added support for proxy http sites.
This commit is contained in:
parent
f9e719d33e
commit
945a9f2af3
4 changed files with 61 additions and 28 deletions
|
@ -100,19 +100,21 @@ define apache::debian::site($aliases, $root, $redirect) {
|
|||
$site_confdir = "/etc/apache2/sites-enabled/${site_fqdn}.d"
|
||||
|
||||
if !$redirect {
|
||||
if $root {
|
||||
file { "/srv/www/http/${site_fqdn}":
|
||||
ensure => link,
|
||||
target => $root,
|
||||
before => File[$site_conf],
|
||||
}
|
||||
} else {
|
||||
file { "/srv/www/http/${site_fqdn}":
|
||||
ensure => directory,
|
||||
mode => "0755",
|
||||
owner => root,
|
||||
group => root,
|
||||
before => File[$site_conf],
|
||||
if !$proxy {
|
||||
if $root {
|
||||
file { "/srv/www/http/${site_fqdn}":
|
||||
ensure => link,
|
||||
target => $root,
|
||||
before => File[$site_conf],
|
||||
}
|
||||
} else {
|
||||
file { "/srv/www/http/${site_fqdn}":
|
||||
ensure => directory,
|
||||
mode => "0755",
|
||||
owner => root,
|
||||
group => root,
|
||||
before => File[$site_conf],
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -138,6 +140,10 @@ define apache::debian::site($aliases, $root, $redirect) {
|
|||
File[$site_conf] {
|
||||
content => "<VirtualHost *:80>\n ServerName ${site_fqdn}\n Redirect permanent / ${redirect}\n</VirtualHost>\n",
|
||||
}
|
||||
} elsif $proxy {
|
||||
File[$site_conf] {
|
||||
content => template("apache/proxy.http.conf.erb"),
|
||||
}
|
||||
} else {
|
||||
File[$site_conf] {
|
||||
content => template("apache/site.http.conf.erb"),
|
||||
|
|
|
@ -154,6 +154,8 @@ class apache::server inherits apache::common {
|
|||
# Path to document root. Defaults to /srv/www/http/$fqdn
|
||||
# $redirect:
|
||||
# Add redirect to given URL.
|
||||
# $proxy:
|
||||
# Proxy site to given URL.
|
||||
#
|
||||
# === Sample usage
|
||||
#
|
||||
|
@ -163,8 +165,15 @@ class apache::server inherits apache::common {
|
|||
# apache::site { "www.example.com":
|
||||
# root => "/roles/prteam/public/public_access",
|
||||
# }
|
||||
# apache::site { "www2.example.com":
|
||||
# proxy => "http://www.example.com",
|
||||
# }
|
||||
#
|
||||
define apache::site($aliases="", $root="", $redirect="") {
|
||||
define apache::site($aliases="", $root="", $redirect="", $proxy="") {
|
||||
|
||||
if $redirect and $proxy {
|
||||
fail("cannot define both \$redirect and \$proxy for apache::site (${name})")
|
||||
}
|
||||
|
||||
case $::operatingsystem {
|
||||
"debian","ubuntu": {
|
||||
|
@ -172,6 +181,7 @@ define apache::site($aliases="", $root="", $redirect="") {
|
|||
aliases => $aliases,
|
||||
root => $root,
|
||||
redirect => $redirect,
|
||||
proxy => $proxy,
|
||||
}
|
||||
}
|
||||
"centos","redhat","fedora": {
|
||||
|
@ -179,6 +189,7 @@ define apache::site($aliases="", $root="", $redirect="") {
|
|||
aliases => $aliases,
|
||||
root => $root,
|
||||
redirect => $redirect,
|
||||
proxy => $proxy,
|
||||
}
|
||||
}
|
||||
default: {
|
||||
|
|
|
@ -45,7 +45,7 @@ class apache::redhat::server {
|
|||
}
|
||||
|
||||
|
||||
define apache::redhat::site($aliases, $root, $redirect) {
|
||||
define apache::redhat::site($aliases, $root, $redirect, $proxy) {
|
||||
|
||||
if $name == "default" {
|
||||
$site_fqdn = $homename
|
||||
|
@ -57,19 +57,21 @@ define apache::redhat::site($aliases, $root, $redirect) {
|
|||
$site_confdir = "/etc/httpd/site.http.d/${site_fqdn}.d"
|
||||
|
||||
if !$redirect {
|
||||
if $root {
|
||||
file { "/srv/www/http/${site_fqdn}":
|
||||
ensure => link,
|
||||
target => $root,
|
||||
before => File[$site_conf],
|
||||
}
|
||||
} else {
|
||||
file { "/srv/www/http/${site_fqdn}":
|
||||
ensure => directory,
|
||||
mode => "0755",
|
||||
owner => root,
|
||||
group => root,
|
||||
before => File[$site_conf],
|
||||
if !$proxy {
|
||||
if $root {
|
||||
file { "/srv/www/http/${site_fqdn}":
|
||||
ensure => link,
|
||||
target => $root,
|
||||
before => File[$site_conf],
|
||||
}
|
||||
} else {
|
||||
file { "/srv/www/http/${site_fqdn}":
|
||||
ensure => directory,
|
||||
mode => "0755",
|
||||
owner => root,
|
||||
group => root,
|
||||
before => File[$site_conf],
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -96,6 +98,10 @@ define apache::redhat::site($aliases, $root, $redirect) {
|
|||
File[$site_conf] {
|
||||
content => "<VirtualHost *:80>\n ServerName ${site_fqdn}\n Redirect permanent / ${redirect}\n</VirtualHost>\n",
|
||||
}
|
||||
} elsif $proxy {
|
||||
File[$site_conf] {
|
||||
content => template("apache/proxy.http.conf.erb"),
|
||||
}
|
||||
} else {
|
||||
File[$site_conf] {
|
||||
content => template("apache/site.http.conf.erb"),
|
||||
|
|
10
apache/templates/proxy.http.conf.erb
Normal file
10
apache/templates/proxy.http.conf.erb
Normal file
|
@ -0,0 +1,10 @@
|
|||
<VirtualHost *:80>
|
||||
ServerName <%= @site_fqdn %>
|
||||
<% if @aliases != "" -%>
|
||||
ServerAlias <%= @aliases %>
|
||||
<% end -%>
|
||||
ErrorLog /srv/www/log/http/<%= @site_fqdn %>/error_log
|
||||
CustomLog /srv/www/log/http/<%= @site_fqdn %>/access_log combined
|
||||
ProxyPass / <%= @proxy %>/
|
||||
ProxyPassReverse / <%= @proxy %>/
|
||||
</VirtualHost>
|
Loading…
Add table
Reference in a new issue