larger net
[mirror/dsa-puppet.git] / modules / roles / manifests / snapshot_web.pp
1 class roles::snapshot_web {
2         include apache2
3         include apache2::rewrite
4
5         # snapshot abusers
6         #  61.69.254.110 - 20180705, mirroring with wget
7         # 20180821 large amount of requests way too fast from some amazon AWS instances
8         #  18.185.157.46
9         #  18.194.174.202
10         #  18.184.181.169
11         #  18.184.5.230
12         #  18.194.137.96
13         #  18.197.147.183
14         #  3.120.39.137
15         #  3.120.41.69
16         #  35.158.129.130
17         #  52.59.199.25
18         #  52.59.228.158
19         #  52.59.245.42
20         #  52.59.253.41
21         #  52.59.71.13
22         @ferm::rule { 'dsa-snapshot-abusers':
23                 prio  => "000",
24                 rule  => "saddr (61.69.254.110 18.128.0.0/9 3.120.0.0/14 35.156.0.0/14 52.58.0.0/15) DROP",
25         }
26
27         ensure_packages ( [
28                 "libapache2-mod-wsgi",
29                 ], {
30                 ensure => 'installed',
31         })
32
33         apache2::site { '020-snapshot.debian.org':
34                 site   => 'snapshot.debian.org',
35                 content => template('roles/snapshot/snapshot.debian.org.conf.erb')
36         }
37
38         case $::hostname {
39                 'lw07': {
40                         $ipv4addr        = '185.17.185.185'
41                         $ipv6addr        = '2001:1af8:4020:b030:deb::185'
42                         $ipv6addr_apache = '2001:1af8:4020:b030:deb::187'
43                 }
44                 'sallinen': {
45                         $ipv4addr        = '193.62.202.27'
46                         $ipv6addr        = '2001:630:206:4000:1a1a:0:c13e:ca1b'
47                         $ipv6addr_apache = '2001:630:206:4000:1a1a:0:c13e:ca1a'
48                 }
49                 default: {
50                         fail ( "unknown host $::hostname for snapshot_web." )
51                 }
52         }
53
54         # varnish cache
55         ###############
56         @ferm::rule { 'dsa-nat-snapshot-varnish-v4':
57                 table => 'nat',
58                 chain => 'PREROUTING',
59                 rule  => "proto tcp daddr ${ipv4addr} dport 80 REDIRECT to-ports 6081",
60         }
61
62         varnish::config { 'default':
63                 listen  => [
64                         ':6081',
65                         "[$ipv6addr]:80"
66                         ],
67                 backend => 'file,/var/lib/varnish/varnish_storage.bin,8G',
68                 content => template('roles/snapshot/snapshot.debian.org.vcl.erb'),
69         }
70
71         # the ipv6 port 80 is owned by varnish
72         file { '/etc/apache2/ports.conf':
73                 content  => @("EOF"),
74                         Listen 0.0.0.0:80
75                         Listen [$ipv6addr_apache]:80
76                         | EOF
77                 require => Package['apache2'],
78                 notify  => Service['apache2'],
79         }
80
81         # haproxy ssl termination
82         #########################
83         include haproxy
84         file { '/etc/haproxy/haproxy.cfg':
85                 content => template('roles/snapshot/haproxy.cfg.erb'),
86                 require => Package['haproxy'],
87                 notify  => Service['haproxy'],
88         }
89         ssl::service { 'snapshot.debian.org':
90                 notify  => Service['haproxy'],
91                 key => true,
92         }
93 }