- # haproxy ssl termination
- #########################
- include haproxy
- file { '/etc/haproxy/haproxy.cfg':
- content => template('roles/snapshot/haproxy.cfg.erb'),
- require => Package['haproxy'],
- notify => Service['haproxy'],
- }
- ssl::service { 'snapshot.debian.org':
- notify => Service['haproxy'],
- key => true,
- }
+ ferm::rule { 'dsa-snapshot-connlimit':
+ domain => '(ip ip6)',
+ prio => '005',
+ rule => "proto tcp mod state state (NEW) interface ! lo daddr (${ipv4addr} ${ipv6addr}) mod multiport destination-ports (80 443) mod connlimit connlimit-above 3 DROP;
+ proto tcp mod state state (NEW) interface ! lo dport 6081 mod connlimit connlimit-above 3 DROP
+ ",
+ }
+
+ # varnish cache
+ ###############
+ ferm::rule { 'dsa-nat-snapshot-varnish-v4':
+ table => 'nat',
+ chain => 'PREROUTING',
+ rule => "proto tcp daddr ${ipv4addr} dport 80 REDIRECT to-ports 6081",
+ }
+
+ varnish::config { 'default':
+ listen => [
+ ':6081',
+ "[${ipv6addr}]:80"
+ ],
+ backend => 'file,/var/lib/varnish/varnish_storage.bin,8G',
+ content => template('roles/snapshot/snapshot.debian.org.vcl.erb'),
+ }
+
+ # the ipv6 port 80 is owned by varnish
+ file { '/etc/apache2/ports.conf':
+ content => @("EOF"),
+ Listen 0.0.0.0:80
+ Listen [${ipv6addr_apache}]:80
+ | EOF
+ require => Package['apache2'],
+ notify => Service['apache2'],
+ }
+
+ # haproxy ssl termination
+ #########################
+ include haproxy
+ file { '/etc/haproxy/haproxy.cfg':
+ content => template('roles/snapshot/haproxy.cfg.erb'),
+ require => Package['haproxy'],
+ notify => Service['haproxy'],
+ }
+ ssl::service { 'snapshot.debian.org':
+ notify => Service['haproxy'],
+ key => true,
+ }