apache: Fix file names with port based SSL virtual hosts

Ubuntu 10.04's apache ignores config files with colons in the name.
This commit is contained in:
Ossi Salmi 2013-11-05 10:16:19 +02:00
parent 7ca414fc9f
commit 1b87c7bd04
2 changed files with 10 additions and 7 deletions

View file

@ -308,8 +308,10 @@ define apache::sslsite($first=false, $hsts=false, $ipaddr="_default_", $root="",
include apache::mod::headers include apache::mod::headers
} }
if $name =~ /:([0-9]+)$/ { if $name =~ /(.*):([0-9]+)$/ {
$port = $1 $site = $1
$port = $2
$name_real = "${site}.${port}"
if ! defined(Apache::Configfile["listen_${port}.conf"]) { if ! defined(Apache::Configfile["listen_${port}.conf"]) {
apache::configfile { "listen_${port}.conf": apache::configfile { "listen_${port}.conf":
http => false, http => false,
@ -318,12 +320,13 @@ define apache::sslsite($first=false, $hsts=false, $ipaddr="_default_", $root="",
} }
} else { } else {
$port = "443" $port = "443"
$name_real = $name
} }
case $::operatingsystem { case $::operatingsystem {
"debian","ubuntu": { "debian","ubuntu": {
$apache_ssldir = "/etc/ssl" $apache_ssldir = "/etc/ssl"
apache::debian::sslsite { $name: apache::debian::sslsite { $name_real:
first => $first, first => $first,
hsts => $hsts, hsts => $hsts,
ipaddr => $ipaddr, ipaddr => $ipaddr,
@ -338,7 +341,7 @@ define apache::sslsite($first=false, $hsts=false, $ipaddr="_default_", $root="",
} }
"centos","redhat","fedora": { "centos","redhat","fedora": {
$apache_ssldir = "/etc/pki/tls" $apache_ssldir = "/etc/pki/tls"
apache::redhat::sslsite { $name: apache::redhat::sslsite { $name_real:
first => $first, first => $first,
hsts => $hsts, hsts => $hsts,
ipaddr => $ipaddr, ipaddr => $ipaddr,
@ -356,9 +359,9 @@ define apache::sslsite($first=false, $hsts=false, $ipaddr="_default_", $root="",
} }
} }
$site_fqdn = $name ? { $site_fqdn = $name_real ? {
"default" => $::homename, "default" => $::homename,
default => $name, default => $name_real,
} }
apache::webalizer::site { "https/${site_fqdn}": apache::webalizer::site { "https/${site_fqdn}":
site_proto => "https", site_proto => "https",

View file

@ -1,7 +1,7 @@
<VirtualHost <%= @ipaddr %>:<%= @port %>> <VirtualHost <%= @ipaddr %>:<%= @port %>>
# General setup for the virtual host, inherited from global configuration # General setup for the virtual host, inherited from global configuration
ServerName <%= @site_fqdn %> ServerName <%= @site_fqdn.sub(/\.([0-9]+)$/, ':\1') %>
# Use separate log files for the SSL virtual host; note that LogLevel # Use separate log files for the SSL virtual host; note that LogLevel
# is not inherited from httpd.conf. # is not inherited from httpd.conf.