2695f002873c85f18c21d5fa94988e73132e1768
[via-proxy] / add-provider.pl
1 #!/usr/bin/perl
2 use warnings;
3 use strict;
4 use autodie;
5
6 my @domains = @ARGV;
7
8 open(my $fh, '>', "providers/$domains[0].conf");
9
10 print $fh qq{# $0 @domains\n\n};
11
12 foreach my $domain ( @domains ) {
13
14 print $fh qq{
15
16 <VirtualHost *:443>
17         Include /srv/via-proxy/ssl.conf
18
19         ServerName ${domain}.p.vbz.ffzg.hr
20
21         SSLProxyEngine on
22         ProxyAddHeaders Off
23         ProxyPass        / https://${domain}/
24         ProxyPassReverse / https://${domain}/
25
26         Header edit* Set-Cookie "(.*)(?i:; *domain=)([^;]+)(.*)" "\$1 ; domain=\$2.p.vbz.ffzg.hr \$3"
27         #Header edit* Set-Cookie "(.*)(?i:; *secure)" "\$1"
28 };
29
30 foreach ( @domains ) {
31         print $fh qq{\tHeader edit* Location "https://$_/" "https://$_.p.vbz.ffzg.hr/"\n};
32 }
33
34 print $fh qq{
35         RequestHeader unset Accept-Encoding
36 };
37
38 foreach ( @domains ) {
39         print $fh qq{\tSubstitute "s|https://$_|https://$_.p.vbz.ffzg.hr|"\n};
40 }
41
42 print $fh qq{
43         FilterDeclare NEWPATHS
44         FilterProvider NEWPATHS SUBSTITUTE "%{Content_Type} =~ m|^text/html|"
45         FilterProvider NEWPATHS SUBSTITUTE "%{Content_Type} =~ m|^text/css|"
46         FilterProvider NEWPATHS SUBSTITUTE "%{Content_Type} =~ m|^text/javascript|"
47         FilterProvider NEWPATHS SUBSTITUTE "%{Content_Type} =~ m|^application/javascript|"
48         FilterChain NEWPATHS
49
50         CustomLog /var/log/apache2/access-p.vbz.ffzg.hr.log vhost_combined
51 </VirtualHost>
52 };
53
54 }
55
56 print $fh "\n\n## add domains to SSL certificate:\n";
57 print "## add domains to SSL certificate:\n";
58 foreach ( @domains ) {
59         print $fh qq{# $_.p.vbz.ffzg.hr\n};
60         print qq{$_.p.vbz.ffzg.hr\n};
61 }