certbot moved certificate to each vhost
[via-proxy] / add-provider.pl
1 #!/usr/bin/perl
2 use warnings;
3 use strict;
4 use autodie;
5
6 my @domains = map { s{^https://}{}; s{/+$}{}; $_ } @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         RewriteEngine on
22         # fix broken chunging
23         #RewriteRule    /common/javascript/extjs/ext-all.js     https://${domain}/common/javascript/extjs/ext-all.js [R,L]
24
25         SSLProxyEngine on
26         ProxyAddHeaders Off
27         ProxyPass        / https://${domain}/
28         ProxyPassReverse / https://${domain}/
29
30         Header edit* Set-Cookie "(.*)(?i:; *domain=)([^;]+)(.*)" "\$1 ; domain=\$2.p.vbz.ffzg.hr \$3"
31         #Header edit* Set-Cookie "(.*)(?i:; *secure)" "\$1"
32 };
33
34 foreach ( @domains ) {
35         # for maximum compatibility, they should NOT end with /
36         print $fh qq{\tHeader edit* Location "https://$_" "https://$_.p.vbz.ffzg.hr"\n};
37 }
38
39 print $fh qq{
40         RequestHeader unset Accept-Encoding
41 };
42
43 foreach ( @domains ) {
44         print $fh qq{\tSubstitute "s|https://$_|https://$_.p.vbz.ffzg.hr|"\n};
45 }
46
47 print $fh qq{
48         FilterDeclare NEWPATHS
49         FilterProvider NEWPATHS SUBSTITUTE "%{Content_Type} =~ m|^text/html|"
50         FilterProvider NEWPATHS SUBSTITUTE "%{Content_Type} =~ m|^text/css|"
51         FilterProvider NEWPATHS SUBSTITUTE "%{Content_Type} =~ m|^text/javascript|"
52         FilterProvider NEWPATHS SUBSTITUTE "%{Content_Type} =~ m|^application/javascript|"
53         FilterChain NEWPATHS
54
55         CustomLog /var/log/apache2/access-p.vbz.ffzg.hr.log vhost_combined
56 </VirtualHost>
57 };
58
59 }
60
61 print $fh "\n\n## add domains to SSL certificate:\n";
62 print "## add domains to SSL certificate:\n";
63 foreach ( @domains ) {
64         print $fh qq{# $_.p.vbz.ffzg.hr\n};
65         print qq{$_.p.vbz.ffzg.hr\n};
66 }