1 # web service for snapshot.debian.org
3 class roles::snapshot_web {
4 include roles::snapshot_secondary
7 include apache2::rewrite
10 # 61.69.254.110 - 20180705, mirroring with wget
11 # 20180821 large amount of requests way too fast from some amazon AWS instances
30 # 20181222, excessive number of requests
33 # running jigdo against snapshot
37 # 20190512 tens of thousands of queries
49 ferm::rule { 'dsa-snapshot-abusers':
51 rule => 'saddr (61.69.254.110 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 95.115.66.23 90.44.107.223 195.154.173.12 74.121.137.108) DROP',
54 # rate limit accesses. The chain is set up by the apache module and allow happens at prio 90.
55 ferm::rule { 'dsa-http-snapshot-limit':
57 description => 'rate limit for snapshot',
61 mod hashlimit hashlimit-name HTTPDOSPRE hashlimit-mode srcip hashlimit-burst 10 hashlimit 6/minute jump ACCEPT;
62 mod recent name HTTPDOS update seconds 900 jump log_or_drop;
63 mod hashlimit hashlimit-name HTTPDOS hashlimit-mode srcip hashlimit-burst 200 hashlimit 30/minute jump ACCEPT;
64 mod recent name HTTPDOS set jump log_or_drop'
68 'libapache2-mod-wsgi',
70 ensure => 'installed',
73 apache2::site { '020-snapshot.debian.org':
74 site => 'snapshot.debian.org',
75 content => template('roles/snapshot/snapshot.debian.org.conf.erb')
80 $ipv4addr = '185.17.185.185'
81 $ipv6addr = '2001:1af8:4020:b030:deb::185'
82 $ipv6addr_apache = '2001:1af8:4020:b030:deb::187'
85 $ipv4addr = '193.62.202.27'
86 $ipv6addr = '2001:630:206:4000:1a1a:0:c13e:ca1b'
87 $ipv6addr_apache = '2001:630:206:4000:1a1a:0:c13e:ca1a'
90 fail ( "unknown host ${::hostname} for snapshot_web." )
94 ferm::rule { 'dsa-snapshot-connlimit':
97 rule => "proto tcp mod state state (NEW) interface ! lo daddr (${ipv4addr} ${ipv6addr}) mod multiport destination-ports (80 443) mod connlimit connlimit-above 3 DROP;
98 proto tcp mod state state (NEW) interface ! lo dport 6081 mod connlimit connlimit-above 3 DROP
104 ferm::rule { 'dsa-nat-snapshot-varnish-v4':
106 chain => 'PREROUTING',
107 rule => "proto tcp daddr ${ipv4addr} dport 80 REDIRECT to-ports 6081",
110 varnish::config { 'default':
115 backend => 'file,/var/lib/varnish/varnish_storage.bin,8G',
116 content => template('roles/snapshot/snapshot.debian.org.vcl.erb'),
119 # the ipv6 port 80 is owned by varnish
120 file { '/etc/apache2/ports.conf':
123 Listen [${ipv6addr_apache}]:80
125 require => Package['apache2'],
126 notify => Service['apache2'],
129 # haproxy ssl termination
130 #########################
132 file { '/etc/haproxy/haproxy.cfg':
133 content => template('roles/snapshot/haproxy.cfg.erb'),
134 require => Package['haproxy'],
135 notify => Service['haproxy'],
137 ssl::service { 'snapshot.debian.org':
138 notify => Service['haproxy'],