From: Dobrica Pavlinusic Date: Thu, 14 Feb 2019 08:11:21 +0000 (+0100) Subject: script to add cluster of domains for same provider X-Git-Url: http://git.rot13.org/?p=via-proxy;a=commitdiff_plain;h=26be5565df8880135cb9aac523ab8bce15724f14 script to add cluster of domains for same provider they are inter-linked and all redirects between them will end up behind proxy --- diff --git a/add-provider.pl b/add-provider.pl new file mode 100755 index 0000000..2695f00 --- /dev/null +++ b/add-provider.pl @@ -0,0 +1,61 @@ +#!/usr/bin/perl +use warnings; +use strict; +use autodie; + +my @domains = @ARGV; + +open(my $fh, '>', "providers/$domains[0].conf"); + +print $fh qq{# $0 @domains\n\n}; + +foreach my $domain ( @domains ) { + +print $fh qq{ + + + Include /srv/via-proxy/ssl.conf + + ServerName ${domain}.p.vbz.ffzg.hr + + SSLProxyEngine on + ProxyAddHeaders Off + ProxyPass / https://${domain}/ + ProxyPassReverse / https://${domain}/ + + Header edit* Set-Cookie "(.*)(?i:; *domain=)([^;]+)(.*)" "\$1 ; domain=\$2.p.vbz.ffzg.hr \$3" + #Header edit* Set-Cookie "(.*)(?i:; *secure)" "\$1" +}; + +foreach ( @domains ) { + print $fh qq{\tHeader edit* Location "https://$_/" "https://$_.p.vbz.ffzg.hr/"\n}; +} + +print $fh qq{ + RequestHeader unset Accept-Encoding +}; + +foreach ( @domains ) { + print $fh qq{\tSubstitute "s|https://$_|https://$_.p.vbz.ffzg.hr|"\n}; +} + +print $fh qq{ + FilterDeclare NEWPATHS + FilterProvider NEWPATHS SUBSTITUTE "%{Content_Type} =~ m|^text/html|" + FilterProvider NEWPATHS SUBSTITUTE "%{Content_Type} =~ m|^text/css|" + FilterProvider NEWPATHS SUBSTITUTE "%{Content_Type} =~ m|^text/javascript|" + FilterProvider NEWPATHS SUBSTITUTE "%{Content_Type} =~ m|^application/javascript|" + FilterChain NEWPATHS + + CustomLog /var/log/apache2/access-p.vbz.ffzg.hr.log vhost_combined + +}; + +} + +print $fh "\n\n## add domains to SSL certificate:\n"; +print "## add domains to SSL certificate:\n"; +foreach ( @domains ) { + print $fh qq{# $_.p.vbz.ffzg.hr\n}; + print qq{$_.p.vbz.ffzg.hr\n}; +}