New virtual host configuration for pacs. Fallback/Default should be HTTP

404.
This commit is contained in:
Michael Hierweck 2017-06-29 09:51:24 +02:00
parent 6365b4f7f5
commit 0cee4abcfe
2 changed files with 29 additions and 20 deletions

View File

@ -90,22 +90,10 @@ public class PacProcessorFactory implements EntityProcessorFactory {
private Processor createHttpdVirtualProc(Hive hive) throws ProcessorException { private Processor createHttpdVirtualProc(Hive hive) throws ProcessorException {
Processor domSetupProcessor = new CompoundProcessor( Processor domSetupProcessor = new CompoundProcessor(
new CreateFileProcessor("/de/hsadmin/mods/pac/httpd-virtual.vm", hive, new CreateFileProcessor("/de/hsadmin/mods/pac/httpd-virtual.vm", hive,
"/etc/apache2/virtual.conf.tmp", "root", "root", "644", true), "/etc/apache2/conf.d/virtual.conf.tmp", "root", "root", "644", true),
new ShellProcessor("for PEM in $( cat /etc/apache2/virtual.conf.tmp | grep SSLCertificateFile | cut -c24- ); do " + new ShellProcessor("(diff -q /etc/apache2/conf.d/virtual.conf.tmp /etc/apache2/conf.d/virtual.conf"
"ls $PEM >/dev/null 2>&1 || ( " + + " && rm /etc/apache2/conf.d/virtual.conf.tmp )"
" sed -i \"/SSLCertificateFile.*${PEM:18}/c \\\n" + + " || ( mv /etc/apache2/conf.d/virtual.conf.tmp /etc/apache2/conf.d/virtual.conf "
"\\ \\ \\ \\ SSLCertificateFile \\/etc\\/apache2\\/pems\\/default.pem\" /etc/apache2/virtual.conf.tmp && " +
" sed -i \"/SSLCertificateChainFile.*${PEM:18:5}.chain.pem/c \\\n" +
"\\ \\ \\ \\ SSLCertificateChainFile \\/etc\\/apache2\\/pems\\/default.chain.pem\" /etc/apache2/virtual.conf.tmp " +
"); " +
"done"),
new ShellProcessor("for PEM in $( cat /etc/apache2/virtual.conf.tmp | grep SSLCertificateChainFile | cut -c29- ); do " +
"ls $PEM >/dev/null 2>&1 || " +
" sed -i \"/SSLCertificateChainFile.*${PEM:18:5}.chain.pem/d \" /etc/apache2/virtual.conf.tmp ; " +
"done"),
new ShellProcessor("(diff -q /etc/apache2/virtual.conf.tmp /etc/apache2/virtual.conf"
+ " && rm /etc/apache2/virtual.conf.tmp )"
+ " || ( mv /etc/apache2/virtual.conf.tmp /etc/apache2/virtual.conf "
+ " && invoke-rc.d apache2 reload >/dev/null 2>&1 ) ")); + " && invoke-rc.d apache2 reload >/dev/null 2>&1 ) "));
return domSetupProcessor; return domSetupProcessor;
} }

View File

@ -4,8 +4,29 @@
# #
#foreach( $pac in ${hive.pacs} ) #foreach( $pac in ${hive.pacs} )
<VirtualHost ${pac.curINetAddr.inetAddr}:80>
ServerName _
ServerAdmin webmaster@${pac.getName}
<Directory />
Redirect 404 /
</Directory>
</VirtualHost>
<VirtualHost ${pac.curINetAddr.inetAddr}:443>
ServerName _
ServerAdmin webmaster@${pac.getName}
SSLEngine On
SSLCertificateFile /etc/apache2/pems/default.pem
SSLCertificateChainFile /etc/apache2/pems/default.chain.pem
<Directory />
SSLRequireSSL On
Redirect 404 /
</Directory>
</VirtualHost>
# ${pac.name}
NameVirtualHost ${pac.curINetAddr.inetAddr}:80
NameVirtualHost ${pac.curINetAddr.inetAddr}:443
#end #end