Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 87f61a6

Browse files
committed
NEW: foreign referrer limits
1 parent 757e137 commit 87f61a6

File tree

5 files changed

+29
-1
lines changed

5 files changed

+29
-1
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
- CHANGED: CID deployment to set env based on .env file
44
- FIXED: pattern-based static file serving config with no apps (try_files)
55
- NEW: docker::custom_args support
6+
- NEW: foreign referrer limits
67

78
# 1.3.2 (2019-11-13)
89
- CHANGED: /www/empty permission to 0755 for CID v0.8.29+ support

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ This module is also a reference implementation of [FutoIn CID](https://github.co
5050
* Apps cannot access each other, nginx service has aux group of each app
5151
* HTTP_PROXY and other known attack mitigation
5252
* Automatic systemd-based restart
53+
* Basic protection against DDoS through victim browsers
5354
* Misc:
5455
* HTTP/2
5556
* Multiple IP/interface aware
@@ -302,8 +303,9 @@ Main resource type to define virtualhost with related apps.
302303
* `verify = on` - override verification mode
303304
* `$hsts = 'max-age=15768000; includeSubDomains; preload'` - HSTS, optional
304305
* enabled only at TLS termination
305-
* `$xfo = 'deny' - X-Frame-Options, optional
306+
* `$xfo = 'deny'` - X-Frame-Options, optional
306307
* enabled only at TLS termination
308+
* `$frl = true` - foreign referrer limit, 50kps after 100kb if Referrer mismatch by default
307309
* `$deploy = undef` - optional deployment strategy parameters
308310

309311
### Deploy strategy

lib/puppet/provider/cfweb_nginx/cfweb.rb

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,19 @@ def self.on_config_change(newconf)
175175
'default' => '$server_name',
176176
'0' => "''",
177177
}
178+
179+
cf_invalid_referer_rate = cfweb_tune.fetch('cf_invalid_referer_rate', '50k')
180+
cf_invalid_referer_rate_after = cfweb_tune.fetch('cf_invalid_referer_rate_after', '100k')
181+
http_conf["map $invalid_referer $cf_invalid_referer_rate"] = {
182+
'default' => '0',
183+
'1' => cf_invalid_referer_rate,
184+
}
185+
http_conf["map $invalid_referer $cf_invalid_referer_rate_after"] = {
186+
'default' => '0',
187+
'1' => cf_invalid_referer_rate_after,
188+
}
189+
http_conf["# variables are supported only since v1.17"] = ''
190+
http_conf["limit_rate_after"] = cf_invalid_referer_rate_after
178191

179192
if stress_hosts && stress_hosts.size then
180193
stress_hosts.each { |shost|

manifests/site.pp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
Optional[CfWeb::ClientX509] $require_x509 = undef,
3838
Optional[String[1]] $hsts = 'max-age=15768000; includeSubDomains; preload',
3939
Optional[String[1]] $xfo = 'deny',
40+
Boolean $frl = true,
4041

4142
Boolean $backup_persistent = true,
4243
) {
@@ -430,6 +431,7 @@
430431
require_x509 => $require_x509,
431432
hsts => $hsts,
432433
xfo => $xfo,
434+
frl => $frl,
433435
}),
434436
notify => $cfg_notify,
435437
before => Anchor['cfnginx-ready'],

templates/app_vhost.epp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
Optional[CfWeb::ClientX509] $require_x509,
2323
Optional[String[1]] $hsts,
2424
Optional[String[1]] $xfo,
25+
Optional[Boolean] $frl,
2526
|
2627

2728
if size($plain_ports) == 0 and size($tls_ports) == 0 {
@@ -97,6 +98,15 @@ $tls_snippet = inline_epp('
9798
add_header X-Frame-Options \'<%= $xfo %>\';
9899
<% } -%>
99100

101+
<% if $frl { -%>
102+
valid_referers server_names;
103+
104+
# Only since nginx 1.17
105+
#limit_rate $cf_invalid_referer_rate;
106+
#limit_rate_after $cf_invalid_referer_rate_after;
107+
set $limit_rate $cf_invalid_referer_rate;
108+
<% } -%>
109+
100110
<% } -%>
101111
', {
102112
})

0 commit comments

Comments
 (0)