Skip to content

Instantly share code, notes, and snippets.

@stesh
Created January 2, 2014 16:23
Show Gist options
  • Save stesh/8221756 to your computer and use it in GitHub Desktop.
Save stesh/8221756 to your computer and use it in GitHub Desktop.
<Perl>
use Apache2::ServerUtil;
my @sites = (
"netsoc.tcd.ie",
"issue.netsoc.tcd.ie",
"meta.netsoc.tcd.ie",
"cubewww.cube-external.netsoc.tcd.ie",
"meecro.netsoc.tcd.ie",
"phpmyadmin.netsoc.tcd.ie",
"nickserv.netsoc.tcd.ie",
"matrix.netsoc.tcd.ie",
"www.netsoc.tcd.ie",
"my.netsoc.tcd.ie",
"oldwww.netsoc.tcd.ie",
"dev.quotes.netsoc.tcd.ie",
"quotes.netsoc.tcd.ie",
"porick.netsoc.tcd.ie",
"boards.netsoc.tcd.ie",
"code.netsoc.tcd.ie",
"signup.netsoc.tcd.ie",
"support.netsoc.tcd.ie",
"dev.netsoc.tcd.ie",
"weblogin.netsoc.tcd.ie",
"wiki.netsoc.tcd.ie",
"mediawiki.netsoc.tcd.ie",
"beta.netsoc.tcd.ie",
"ugh.netsoc.tcd.ie",
"netsoc2012.netsoc.tcd.ie",
);
my $directive = "ServerAlias";
my $aliases = "$directive ".(join("\n$directive ", @sites));
my $conf = <<EOC;
<VirtualHost 134.226.83.42:80>
ServerName blah
$aliases
ProxyRequests Off
ProxyPreserveHost On
ProxyPass / http://134.226.83.67:80/ retry=0
ProxyPassReverse / http://134.226.83.67:80/
</VirtualHost>
<VirtualHost 134.226.83.42:443>
ServerName blah
$aliases
SSLEngine on
SSLProxyEngine on
SSLCertificateFile /etc/apache2/ssl/star.netsoc.tcd.ie_cert.pem
SSLCertificateKeyFile /etc/apache2/ssl/star.netsoc.tcd.ie_key.pem
ProxyRequests Off
ProxyPreserveHost On
ProxyPass / https://134.226.83.67:443/ retry=0
ProxyPassReverse / https://134.226.83.67:443/
</VirtualHost>
EOC
Apache2::ServerUtil->server->add_config([split /\n/, $conf]);
</Perl>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment