blacklist 95.115.66.23
[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         # 20180821 mirroring
23         #  99.137.191.34
24         # 20181110 crawler
25         #  51.15.215.91
26         # 20181222, excessive number of requests
27         #  208.91.68.213
28         # 198.11.128.0/18
29         # running jugdo against snapshot
30         #  159.226.95.0/24
31         #  84.204.194.0/24
32         #  211.13.205.0/24
33         # 20190512 tens of thousands of queries
34         #  63.32.0.0/14
35         #  95.115.66.23
36         @ferm::rule { 'dsa-snapshot-abusers':
37                 prio  => "005",
38                 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 99.137.191.34 51.15.215.91 208.91.68.213 198.11.128.0/18 159.226.95.0/24 84.204.194.0/24 211.13.205.0/24 63.32.0.0/14 95.115.66.23) DROP",
39         }
40
41         ensure_packages ( [
42                 "libapache2-mod-wsgi",
43                 ], {
44                 ensure => 'installed',
45         })
46
47         apache2::site { '020-snapshot.debian.org':
48                 site   => 'snapshot.debian.org',
49                 content => template('roles/snapshot/snapshot.debian.org.conf.erb')
50         }
51
52         case $::hostname {
53                 'lw07': {
54                         $ipv4addr        = '185.17.185.185'
55                         $ipv6addr        = '2001:1af8:4020:b030:deb::185'
56                         $ipv6addr_apache = '2001:1af8:4020:b030:deb::187'
57                 }
58                 'sallinen': {
59                         $ipv4addr        = '193.62.202.27'
60                         $ipv6addr        = '2001:630:206:4000:1a1a:0:c13e:ca1b'
61                         $ipv6addr_apache = '2001:630:206:4000:1a1a:0:c13e:ca1a'
62                 }
63                 default: {
64                         fail ( "unknown host $::hostname for snapshot_web." )
65                 }
66         }
67
68         @ferm::rule { 'dsa-snapshot-connlimit':
69                 domain => '(ip ip6)',
70                 prio  => "005",
71                 rule  => "proto tcp mod state state (NEW) interface ! lo daddr (${ipv4addr} ${ipv6addr})  mod multiport destination-ports (80 443) mod connlimit connlimit-above 3 DROP;
72                           proto tcp mod state state (NEW) interface ! lo                                                dport 6081                 mod connlimit connlimit-above 3 DROP
73                            ",
74         }
75
76         # varnish cache
77         ###############
78         @ferm::rule { 'dsa-nat-snapshot-varnish-v4':
79                 table => 'nat',
80                 chain => 'PREROUTING',
81                 rule  => "proto tcp daddr ${ipv4addr} dport 80 REDIRECT to-ports 6081",
82         }
83
84         varnish::config { 'default':
85                 listen  => [
86                         ':6081',
87                         "[$ipv6addr]:80"
88                         ],
89                 backend => 'file,/var/lib/varnish/varnish_storage.bin,8G',
90                 content => template('roles/snapshot/snapshot.debian.org.vcl.erb'),
91         }
92
93         # the ipv6 port 80 is owned by varnish
94         file { '/etc/apache2/ports.conf':
95                 content  => @("EOF"),
96                         Listen 0.0.0.0:80
97                         Listen [$ipv6addr_apache]:80
98                         | EOF
99                 require => Package['apache2'],
100                 notify  => Service['apache2'],
101         }
102
103         # haproxy ssl termination
104         #########################
105         include haproxy
106         file { '/etc/haproxy/haproxy.cfg':
107                 content => template('roles/snapshot/haproxy.cfg.erb'),
108                 require => Package['haproxy'],
109                 notify  => Service['haproxy'],
110         }
111         ssl::service { 'snapshot.debian.org':
112                 notify  => Service['haproxy'],
113                 key => true,
114         }
115 }