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"
|
$site_confdir = "/etc/apache2/sites-enabled/${site_fqdn}.d"
|
||||||
|
|
||||||
if !$redirect {
|
if !$redirect {
|
||||||
if $root {
|
if !$proxy {
|
||||||
file { "/srv/www/http/${site_fqdn}":
|
if $root {
|
||||||
ensure => link,
|
file { "/srv/www/http/${site_fqdn}":
|
||||||
target => $root,
|
ensure => link,
|
||||||
before => File[$site_conf],
|
target => $root,
|
||||||
}
|
before => File[$site_conf],
|
||||||
} else {
|
}
|
||||||
file { "/srv/www/http/${site_fqdn}":
|
} else {
|
||||||
ensure => directory,
|
file { "/srv/www/http/${site_fqdn}":
|
||||||
mode => "0755",
|
ensure => directory,
|
||||||
owner => root,
|
mode => "0755",
|
||||||
group => root,
|
owner => root,
|
||||||
before => File[$site_conf],
|
group => root,
|
||||||
|
before => File[$site_conf],
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -138,6 +140,10 @@ define apache::debian::site($aliases, $root, $redirect) {
|
||||||
File[$site_conf] {
|
File[$site_conf] {
|
||||||
content => "<VirtualHost *:80>\n ServerName ${site_fqdn}\n Redirect permanent / ${redirect}\n</VirtualHost>\n",
|
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 {
|
} else {
|
||||||
File[$site_conf] {
|
File[$site_conf] {
|
||||||
content => template("apache/site.http.conf.erb"),
|
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
|
# Path to document root. Defaults to /srv/www/http/$fqdn
|
||||||
# $redirect:
|
# $redirect:
|
||||||
# Add redirect to given URL.
|
# Add redirect to given URL.
|
||||||
|
# $proxy:
|
||||||
|
# Proxy site to given URL.
|
||||||
#
|
#
|
||||||
# === Sample usage
|
# === Sample usage
|
||||||
#
|
#
|
||||||
|
@ -163,8 +165,15 @@ class apache::server inherits apache::common {
|
||||||
# apache::site { "www.example.com":
|
# apache::site { "www.example.com":
|
||||||
# root => "/roles/prteam/public/public_access",
|
# 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 {
|
case $::operatingsystem {
|
||||||
"debian","ubuntu": {
|
"debian","ubuntu": {
|
||||||
|
@ -172,6 +181,7 @@ define apache::site($aliases="", $root="", $redirect="") {
|
||||||
aliases => $aliases,
|
aliases => $aliases,
|
||||||
root => $root,
|
root => $root,
|
||||||
redirect => $redirect,
|
redirect => $redirect,
|
||||||
|
proxy => $proxy,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
"centos","redhat","fedora": {
|
"centos","redhat","fedora": {
|
||||||
|
@ -179,6 +189,7 @@ define apache::site($aliases="", $root="", $redirect="") {
|
||||||
aliases => $aliases,
|
aliases => $aliases,
|
||||||
root => $root,
|
root => $root,
|
||||||
redirect => $redirect,
|
redirect => $redirect,
|
||||||
|
proxy => $proxy,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
default: {
|
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" {
|
if $name == "default" {
|
||||||
$site_fqdn = $homename
|
$site_fqdn = $homename
|
||||||
|
@ -57,19 +57,21 @@ define apache::redhat::site($aliases, $root, $redirect) {
|
||||||
$site_confdir = "/etc/httpd/site.http.d/${site_fqdn}.d"
|
$site_confdir = "/etc/httpd/site.http.d/${site_fqdn}.d"
|
||||||
|
|
||||||
if !$redirect {
|
if !$redirect {
|
||||||
if $root {
|
if !$proxy {
|
||||||
file { "/srv/www/http/${site_fqdn}":
|
if $root {
|
||||||
ensure => link,
|
file { "/srv/www/http/${site_fqdn}":
|
||||||
target => $root,
|
ensure => link,
|
||||||
before => File[$site_conf],
|
target => $root,
|
||||||
}
|
before => File[$site_conf],
|
||||||
} else {
|
}
|
||||||
file { "/srv/www/http/${site_fqdn}":
|
} else {
|
||||||
ensure => directory,
|
file { "/srv/www/http/${site_fqdn}":
|
||||||
mode => "0755",
|
ensure => directory,
|
||||||
owner => root,
|
mode => "0755",
|
||||||
group => root,
|
owner => root,
|
||||||
before => File[$site_conf],
|
group => root,
|
||||||
|
before => File[$site_conf],
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -96,6 +98,10 @@ define apache::redhat::site($aliases, $root, $redirect) {
|
||||||
File[$site_conf] {
|
File[$site_conf] {
|
||||||
content => "<VirtualHost *:80>\n ServerName ${site_fqdn}\n Redirect permanent / ${redirect}\n</VirtualHost>\n",
|
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 {
|
} else {
|
||||||
File[$site_conf] {
|
File[$site_conf] {
|
||||||
content => template("apache/site.http.conf.erb"),
|
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