1 class roles::snapshot_web {
2 include roles::snapshot_base
5 include apache2::rewrite
8 # 61.69.254.110 - 20180705, mirroring with wget
9 # 20180821 large amount of requests way too fast from some amazon AWS instances
28 # 20181222, excessive number of requests
31 # running jugdo against snapshot
35 # 20190512 tens of thousands of queries
47 ferm::rule { 'dsa-snapshot-abusers':
49 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 54.72.0.0/15 95.115.66.23 52.192.0.0/11 54.72.0.0/15 34.192.0.0/10 34.240.0.0/13 52.192.0.0/11 90.44.107.223 195.154.173.12 74.121.137.108) DROP',
52 # rate limit accesses. The chain is set up by the apache module and allow happens at prio 90.
53 ferm::rule { 'dsa-http-snapshot-limit':
55 description => 'rate limit for snapshot',
59 mod hashlimit hashlimit-name HTTPDOSPRE hashlimit-mode srcip hashlimit-burst 10 hashlimit 6/minute jump ACCEPT;
60 mod recent name HTTPDOS update seconds 900 jump log_or_drop;
61 mod hashlimit hashlimit-name HTTPDOS hashlimit-mode srcip hashlimit-burst 200 hashlimit 30/minute jump ACCEPT;
62 mod recent name HTTPDOS set jump log_or_drop'
66 'libapache2-mod-wsgi',
68 ensure => 'installed',
71 apache2::site { '020-snapshot.debian.org':
72 site => 'snapshot.debian.org',
73 content => template('roles/snapshot/snapshot.debian.org.conf.erb')
78 $ipv4addr = '185.17.185.185'
79 $ipv6addr = '2001:1af8:4020:b030:deb::185'
80 $ipv6addr_apache = '2001:1af8:4020:b030:deb::187'
83 $ipv4addr = '193.62.202.27'
84 $ipv6addr = '2001:630:206:4000:1a1a:0:c13e:ca1b'
85 $ipv6addr_apache = '2001:630:206:4000:1a1a:0:c13e:ca1a'
88 fail ( "unknown host ${::hostname} for snapshot_web." )
92 ferm::rule { 'dsa-snapshot-connlimit':
95 rule => "proto tcp mod state state (NEW) interface ! lo daddr (${ipv4addr} ${ipv6addr}) mod multiport destination-ports (80 443) mod connlimit connlimit-above 3 DROP;
96 proto tcp mod state state (NEW) interface ! lo dport 6081 mod connlimit connlimit-above 3 DROP
102 ferm::rule { 'dsa-nat-snapshot-varnish-v4':
104 chain => 'PREROUTING',
105 rule => "proto tcp daddr ${ipv4addr} dport 80 REDIRECT to-ports 6081",
108 varnish::config { 'default':
113 backend => 'file,/var/lib/varnish/varnish_storage.bin,8G',
114 content => template('roles/snapshot/snapshot.debian.org.vcl.erb'),
117 # the ipv6 port 80 is owned by varnish
118 file { '/etc/apache2/ports.conf':
121 Listen [${ipv6addr_apache}]:80
123 require => Package['apache2'],
124 notify => Service['apache2'],
127 # haproxy ssl termination
128 #########################
130 file { '/etc/haproxy/haproxy.cfg':
131 content => template('roles/snapshot/haproxy.cfg.erb'),
132 require => Package['haproxy'],
133 notify => Service['haproxy'],
135 ssl::service { 'snapshot.debian.org':
136 notify => Service['haproxy'],