deploy_mate 0.18.1 → 0.18.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c8a1c17d990ca37d1330258385fca3b2197ab656
4
- data.tar.gz: 162e91f90cc01f3a9384d17bad97034177dc554c
3
+ metadata.gz: 1c147b5057ab98f1b7d09135001e7429c94e4351
4
+ data.tar.gz: 5c887841bef0409e4546798816488780dd3d4f5c
5
5
  SHA512:
6
- metadata.gz: 9269bce666c20f07e473fa2679ba67466010969fff2631dea5202f54e416c76b683846246349b41a23c73fe235cdbb2ca33cc9c48444d9074c47a4916df74003
7
- data.tar.gz: 476c9bad746e56bd82d2d60be897c66c72a04ef4a882c5511691629d648ccc2ca8ff9564d4e247a3833c1e61bf5c0bec0f9831d17b1cfe7926934544a0d70eb1
6
+ metadata.gz: baf968bb63926b1a15a0603536de6d5d49c15afaeae205ef5486ed4088e530a9abadbd65c2c1f0dd25522d75eac184cabfce90c0b108d57f2842c776c98537de
7
+ data.tar.gz: f26223846beef52a51e4be1c13904ef7b61a8a4268a729bb2b424d3b84404a06d9b716c637d2d0a27ac54164acf150be996183ebb6bbf2fd14635f7de117c039
data/README.md CHANGED
@@ -29,6 +29,7 @@ It uses the following Capistrano-roles to divide the installed components:
29
29
  - **cronjobs**: [OPTIONAL] For environments where `whenever` should manage/run cronjobs
30
30
 
31
31
  ## Changelog
32
+ * **0.18.2 (2016-03-08)**: Added basic DDoS and flooding-proof via nginx `req_limit` and `fail2ban`
32
33
  * **0.18.1 (2016-03-01)**: Added support for memcached
33
34
  * **0.18 (2016-02-25)**: Added support for capistrano 3.4, Ask before overwriting existing config-files
34
35
  * **2016-02-19**: Made selection of a deployed branch possible
data/deploy-mate.gemspec CHANGED
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = "deploy_mate"
3
- s.version = "0.18.1"
3
+ s.version = "0.18.2"
4
4
 
5
5
  s.authors = ["Tim Adler", "Marcus Geißler", "Johannes Strampe"]
6
6
  s.date = %q{2016-02-17}
@@ -0,0 +1,13 @@
1
+ # Fail2Ban configuration file
2
+ #
3
+ # supports: ngx_http_limit_req_module module
4
+
5
+ [Definition]
6
+
7
+ failregex = limiting requests, excess:.* by zone.*client: <HOST>
8
+
9
+ # Option: ignoreregex
10
+ # Notes.: regex to ignore. If this regex matches, the line is ignored.
11
+ # Values: TEXT
12
+ #
13
+ ignoreregex =
@@ -0,0 +1,494 @@
1
+ # Fail2Ban configuration file.
2
+ #
3
+ # This file was composed for Debian systems from the original one
4
+ # provided now under /usr/share/doc/fail2ban/examples/jail.conf
5
+ # for additional examples.
6
+ #
7
+ # Comments: use '#' for comment lines and ';' for inline comments
8
+ #
9
+ # To avoid merges during upgrades DO NOT MODIFY THIS FILE
10
+ # and rather provide your changes in /etc/fail2ban/jail.local
11
+ #
12
+
13
+ # The DEFAULT allows a global definition of the options. They can be overridden
14
+ # in each jail afterwards.
15
+
16
+ [DEFAULT]
17
+
18
+ # "ignoreip" can be an IP address, a CIDR mask or a DNS host. Fail2ban will not
19
+ # ban a host which matches an address in this list. Several addresses can be
20
+ # defined using space separator.
21
+ ignoreip = 127.0.0.1/8 217.111.74.210
22
+
23
+ # "bantime" is the number of seconds that a host is banned.
24
+ bantime = 600
25
+
26
+ # A host is banned if it has generated "maxretry" during the last "findtime"
27
+ # seconds.
28
+ findtime = 600
29
+ maxretry = 3
30
+
31
+ # "backend" specifies the backend used to get files modification.
32
+ # Available options are "pyinotify", "gamin", "polling" and "auto".
33
+ # This option can be overridden in each jail as well.
34
+ #
35
+ # pyinotify: requires pyinotify (a file alteration monitor) to be installed.
36
+ # If pyinotify is not installed, Fail2ban will use auto.
37
+ # gamin: requires Gamin (a file alteration monitor) to be installed.
38
+ # If Gamin is not installed, Fail2ban will use auto.
39
+ # polling: uses a polling algorithm which does not require external libraries.
40
+ # auto: will try to use the following backends, in order:
41
+ # pyinotify, gamin, polling.
42
+ backend = auto
43
+
44
+ # "usedns" specifies if jails should trust hostnames in logs,
45
+ # warn when reverse DNS lookups are performed, or ignore all hostnames in logs
46
+ #
47
+ # yes: if a hostname is encountered, a reverse DNS lookup will be performed.
48
+ # warn: if a hostname is encountered, a reverse DNS lookup will be performed,
49
+ # but it will be logged as a warning.
50
+ # no: if a hostname is encountered, will not be used for banning,
51
+ # but it will be logged as info.
52
+ usedns = warn
53
+
54
+ #
55
+ # Destination email address used solely for the interpolations in
56
+ # jail.{conf,local} configuration files.
57
+ destemail = root@localhost
58
+
59
+ #
60
+ # Name of the sender for mta actions
61
+ sendername = Fail2Ban
62
+
63
+ #
64
+ # ACTIONS
65
+ #
66
+
67
+ # Default banning action (e.g. iptables, iptables-new,
68
+ # iptables-multiport, shorewall, etc) It is used to define
69
+ # action_* variables. Can be overridden globally or per
70
+ # section within jail.local file
71
+ banaction = iptables-multiport
72
+
73
+ # email action. Since 0.8.1 upstream fail2ban uses sendmail
74
+ # MTA for the mailing. Change mta configuration parameter to mail
75
+ # if you want to revert to conventional 'mail'.
76
+ mta = sendmail
77
+
78
+ # Default protocol
79
+ protocol = tcp
80
+
81
+ # Specify chain where jumps would need to be added in iptables-* actions
82
+ chain = INPUT
83
+
84
+ #
85
+ # Action shortcuts. To be used to define action parameter
86
+
87
+ # The simplest action to take: ban only
88
+ action_ = %(banaction)s[name=%(__name__)s, port="%(port)s", protocol="%(protocol)s", chain="%(chain)s"]
89
+
90
+ # ban & send an e-mail with whois report to the destemail.
91
+ action_mw = %(banaction)s[name=%(__name__)s, port="%(port)s", protocol="%(protocol)s", chain="%(chain)s"]
92
+ %(mta)s-whois[name=%(__name__)s, dest="%(destemail)s", protocol="%(protocol)s", chain="%(chain)s", sendername="%(sendername)s"]
93
+
94
+ # ban & send an e-mail with whois report and relevant log lines
95
+ # to the destemail.
96
+ action_mwl = %(banaction)s[name=%(__name__)s, port="%(port)s", protocol="%(protocol)s", chain="%(chain)s"]
97
+ %(mta)s-whois-lines[name=%(__name__)s, dest="%(destemail)s", logpath=%(logpath)s, chain="%(chain)s", sendername="%(sendername)s"]
98
+
99
+ # Choose default action. To change, just override value of 'action' with the
100
+ # interpolation to the chosen action shortcut (e.g. action_mw, action_mwl, etc) in jail.local
101
+ # globally (section [DEFAULT]) or per specific section
102
+ action = %(action_)s
103
+
104
+ #
105
+ # JAILS
106
+ #
107
+
108
+ # Next jails corresponds to the standard configuration in Fail2ban 0.6 which
109
+ # was shipped in Debian. Enable any defined here jail by including
110
+ #
111
+ # [SECTION_NAME]
112
+ # enabled = true
113
+
114
+ #
115
+ # in /etc/fail2ban/jail.local.
116
+ #
117
+ # Optionally you may override any other parameter (e.g. banaction,
118
+ # action, port, logpath, etc) in that section within jail.local
119
+
120
+ [ssh]
121
+
122
+ enabled = true
123
+ port = ssh
124
+ filter = sshd
125
+ logpath = /var/log/auth.log
126
+ maxretry = 6
127
+
128
+ [dropbear]
129
+
130
+ enabled = false
131
+ port = ssh
132
+ filter = dropbear
133
+ logpath = /var/log/auth.log
134
+ maxretry = 6
135
+
136
+ # Generic filter for pam. Has to be used with action which bans all ports
137
+ # such as iptables-allports, shorewall
138
+ [pam-generic]
139
+
140
+ enabled = false
141
+ # pam-generic filter can be customized to monitor specific subset of 'tty's
142
+ filter = pam-generic
143
+ # port actually must be irrelevant but lets leave it all for some possible uses
144
+ port = all
145
+ banaction = iptables-allports
146
+ port = anyport
147
+ logpath = /var/log/auth.log
148
+ maxretry = 6
149
+
150
+ [xinetd-fail]
151
+
152
+ enabled = false
153
+ filter = xinetd-fail
154
+ port = all
155
+ banaction = iptables-multiport-log
156
+ logpath = /var/log/daemon.log
157
+ maxretry = 2
158
+
159
+
160
+ [ssh-ddos]
161
+
162
+ enabled = false
163
+ port = ssh
164
+ filter = sshd-ddos
165
+ logpath = /var/log/auth.log
166
+ maxretry = 6
167
+
168
+
169
+ # Here we use blackhole routes for not requiring any additional kernel support
170
+ # to store large volumes of banned IPs
171
+
172
+ [ssh-route]
173
+
174
+ enabled = false
175
+ filter = sshd
176
+ action = route
177
+ logpath = /var/log/sshd.log
178
+ maxretry = 6
179
+
180
+ # Here we use a combination of Netfilter/Iptables and IPsets
181
+ # for storing large volumes of banned IPs
182
+ #
183
+ # IPset comes in two versions. See ipset -V for which one to use
184
+ # requires the ipset package and kernel support.
185
+ [ssh-iptables-ipset4]
186
+
187
+ enabled = false
188
+ port = ssh
189
+ filter = sshd
190
+ banaction = iptables-ipset-proto4
191
+ logpath = /var/log/sshd.log
192
+ maxretry = 6
193
+
194
+ [ssh-iptables-ipset6]
195
+
196
+ enabled = false
197
+ port = ssh
198
+ filter = sshd
199
+ banaction = iptables-ipset-proto6
200
+ logpath = /var/log/sshd.log
201
+ maxretry = 6
202
+
203
+
204
+ #
205
+ # HTTP servers
206
+ #
207
+
208
+ [apache]
209
+
210
+ enabled = false
211
+ port = http,https
212
+ filter = apache-auth
213
+ logpath = /var/log/apache*/*error.log
214
+ maxretry = 6
215
+
216
+ # default action is now multiport, so apache-multiport jail was left
217
+ # for compatibility with previous (<0.7.6-2) releases
218
+ [apache-multiport]
219
+
220
+ enabled = false
221
+ port = http,https
222
+ filter = apache-auth
223
+ logpath = /var/log/apache*/*error.log
224
+ maxretry = 6
225
+
226
+ [apache-noscript]
227
+
228
+ enabled = false
229
+ port = http,https
230
+ filter = apache-noscript
231
+ logpath = /var/log/apache*/*error.log
232
+ maxretry = 6
233
+
234
+ [apache-overflows]
235
+
236
+ enabled = false
237
+ port = http,https
238
+ filter = apache-overflows
239
+ logpath = /var/log/apache*/*error.log
240
+ maxretry = 2
241
+
242
+ # Ban attackers that try to use PHP's URL-fopen() functionality
243
+ # through GET/POST variables. - Experimental, with more than a year
244
+ # of usage in production environments.
245
+
246
+ [php-url-fopen]
247
+
248
+ enabled = false
249
+ port = http,https
250
+ filter = php-url-fopen
251
+ logpath = /var/www/*/logs/access_log
252
+
253
+ # A simple PHP-fastcgi jail which works with lighttpd.
254
+ # If you run a lighttpd server, then you probably will
255
+ # find these kinds of messages in your error_log:
256
+ # ALERT – tried to register forbidden variable ‘GLOBALS’
257
+ # through GET variables (attacker '1.2.3.4', file '/var/www/default/htdocs/index.php')
258
+
259
+ [lighttpd-fastcgi]
260
+
261
+ enabled = false
262
+ port = http,https
263
+ filter = lighttpd-fastcgi
264
+ logpath = /var/log/lighttpd/error.log
265
+
266
+ # Same as above for mod_auth
267
+ # It catches wrong authentifications
268
+
269
+ [lighttpd-auth]
270
+
271
+ enabled = false
272
+ port = http,https
273
+ filter = suhosin
274
+ logpath = /var/log/lighttpd/error.log
275
+
276
+ [nginx-http-auth]
277
+
278
+ enabled = false
279
+ filter = nginx-http-auth
280
+ port = http,https
281
+ logpath = /var/log/nginx/error.log
282
+
283
+ # Monitor roundcube server
284
+
285
+ [roundcube-auth]
286
+
287
+ enabled = false
288
+ filter = roundcube-auth
289
+ port = http,https
290
+ logpath = /var/log/roundcube/userlogins
291
+
292
+
293
+ [sogo-auth]
294
+
295
+ enabled = false
296
+ filter = sogo-auth
297
+ port = http, https
298
+ # without proxy this would be:
299
+ # port = 20000
300
+ logpath = /var/log/sogo/sogo.log
301
+
302
+
303
+ #
304
+ # FTP servers
305
+ #
306
+
307
+ [vsftpd]
308
+
309
+ enabled = false
310
+ port = ftp,ftp-data,ftps,ftps-data
311
+ filter = vsftpd
312
+ logpath = /var/log/vsftpd.log
313
+ # or overwrite it in jails.local to be
314
+ # logpath = /var/log/auth.log
315
+ # if you want to rely on PAM failed login attempts
316
+ # vsftpd's failregex should match both of those formats
317
+ maxretry = 6
318
+
319
+
320
+ [proftpd]
321
+
322
+ enabled = false
323
+ port = ftp,ftp-data,ftps,ftps-data
324
+ filter = proftpd
325
+ logpath = /var/log/proftpd/proftpd.log
326
+ maxretry = 6
327
+
328
+
329
+ [pure-ftpd]
330
+
331
+ enabled = false
332
+ port = ftp,ftp-data,ftps,ftps-data
333
+ filter = pure-ftpd
334
+ logpath = /var/log/syslog
335
+ maxretry = 6
336
+
337
+
338
+ [wuftpd]
339
+
340
+ enabled = false
341
+ port = ftp,ftp-data,ftps,ftps-data
342
+ filter = wuftpd
343
+ logpath = /var/log/syslog
344
+ maxretry = 6
345
+
346
+
347
+ #
348
+ # Mail servers
349
+ #
350
+
351
+ [postfix]
352
+
353
+ enabled = false
354
+ port = smtp,ssmtp,submission
355
+ filter = postfix
356
+ logpath = /var/log/mail.log
357
+
358
+
359
+ [couriersmtp]
360
+
361
+ enabled = false
362
+ port = smtp,ssmtp,submission
363
+ filter = couriersmtp
364
+ logpath = /var/log/mail.log
365
+
366
+
367
+ #
368
+ # Mail servers authenticators: might be used for smtp,ftp,imap servers, so
369
+ # all relevant ports get banned
370
+ #
371
+
372
+ [courierauth]
373
+
374
+ enabled = false
375
+ port = smtp,ssmtp,submission,imap2,imap3,imaps,pop3,pop3s
376
+ filter = courierlogin
377
+ logpath = /var/log/mail.log
378
+
379
+
380
+ [sasl]
381
+
382
+ enabled = false
383
+ port = smtp,ssmtp,submission,imap2,imap3,imaps,pop3,pop3s
384
+ filter = postfix-sasl
385
+ # You might consider monitoring /var/log/mail.warn instead if you are
386
+ # running postfix since it would provide the same log lines at the
387
+ # "warn" level but overall at the smaller filesize.
388
+ logpath = /var/log/mail.log
389
+
390
+ [dovecot]
391
+
392
+ enabled = false
393
+ port = smtp,ssmtp,submission,imap2,imap3,imaps,pop3,pop3s
394
+ filter = dovecot
395
+ logpath = /var/log/mail.log
396
+
397
+ # To log wrong MySQL access attempts add to /etc/my.cnf:
398
+ # log-error=/var/log/mysqld.log
399
+ # log-warning = 2
400
+ [mysqld-auth]
401
+
402
+ enabled = false
403
+ filter = mysqld-auth
404
+ port = 3306
405
+ logpath = /var/log/mysqld.log
406
+
407
+
408
+ # DNS Servers
409
+
410
+
411
+ # These jails block attacks against named (bind9). By default, logging is off
412
+ # with bind9 installation. You will need something like this:
413
+ #
414
+ # logging {
415
+ # channel security_file {
416
+ # file "/var/log/named/security.log" versions 3 size 30m;
417
+ # severity dynamic;
418
+ # print-time yes;
419
+ # };
420
+ # category security {
421
+ # security_file;
422
+ # };
423
+ # };
424
+ #
425
+ # in your named.conf to provide proper logging
426
+
427
+ # !!! WARNING !!!
428
+ # Since UDP is connection-less protocol, spoofing of IP and imitation
429
+ # of illegal actions is way too simple. Thus enabling of this filter
430
+ # might provide an easy way for implementing a DoS against a chosen
431
+ # victim. See
432
+ # http://nion.modprobe.de/blog/archives/690-fail2ban-+-dns-fail.html
433
+ # Please DO NOT USE this jail unless you know what you are doing.
434
+ #[named-refused-udp]
435
+ #
436
+ #enabled = false
437
+ #port = domain,953
438
+ #protocol = udp
439
+ #filter = named-refused
440
+ #logpath = /var/log/named/security.log
441
+
442
+ [named-refused-tcp]
443
+
444
+ enabled = false
445
+ port = domain,953
446
+ protocol = tcp
447
+ filter = named-refused
448
+ logpath = /var/log/named/security.log
449
+
450
+ # Multiple jails, 1 per protocol, are necessary ATM:
451
+ # see https://github.com/fail2ban/fail2ban/issues/37
452
+ [asterisk-tcp]
453
+
454
+ enabled = false
455
+ filter = asterisk
456
+ port = 5060,5061
457
+ protocol = tcp
458
+ logpath = /var/log/asterisk/messages
459
+
460
+ [asterisk-udp]
461
+
462
+ enabled = false
463
+ filter = asterisk
464
+ port = 5060,5061
465
+ protocol = udp
466
+ logpath = /var/log/asterisk/messages
467
+
468
+
469
+ # Jail for more extended banning of persistent abusers
470
+ # !!! WARNING !!!
471
+ # Make sure that your loglevel specified in fail2ban.conf/.local
472
+ # is not at DEBUG level -- which might then cause fail2ban to fall into
473
+ # an infinite loop constantly feeding itself with non-informative lines
474
+ [recidive]
475
+
476
+ enabled = false
477
+ filter = recidive
478
+ logpath = /var/log/fail2ban.log
479
+ action = iptables-allports[name=recidive]
480
+ sendmail-whois-lines[name=recidive, logpath=/var/log/fail2ban.log]
481
+ bantime = 604800 ; 1 week
482
+ findtime = 86400 ; 1 day
483
+ maxretry = 5
484
+
485
+
486
+ [nginx-req-limit]
487
+
488
+ enabled = true
489
+ filter = nginx-req-limit
490
+ action = iptables-multiport[name=ReqLimit, port="http,https", protocol=tcp]
491
+ logpath = <%= shared_path %>/log/nginx_error.log
492
+ findtime = 600
493
+ bantime = 7200
494
+ maxretry = 50
@@ -2,6 +2,8 @@ upstream appserver_upstream {
2
2
  server unix:<%= shared_path %>/system/sockets/<%= fetch(:app_server) %>.sock;
3
3
  }
4
4
 
5
+ limit_req_zone $binary_remote_addr zone=rate_limit:10m rate=10r/s;
6
+
5
7
  server {
6
8
  listen 80;
7
9
  server_name <%= fetch(:nginx_server_name) %>;
@@ -16,6 +18,9 @@ server {
16
18
  root <%= current_path %>/public;
17
19
 
18
20
  location @<%= fetch(:application) %> {
21
+ limit_req zone=rate_limit burst=20;
22
+ limit_req_status 444;
23
+
19
24
  proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
20
25
  proxy_set_header X-Forwarded-Proto $scheme;
21
26
  proxy_set_header Host $http_host;
@@ -28,6 +28,6 @@ require "capistrano/helpers.rb"
28
28
  end
29
29
 
30
30
  # Loads custom tasks from `lib/capistrano/tasks' if you have any defined.
31
- %w(bluepill logrotate machine elasticsearch nginx rvm unicorn puma upstart).each do |t|
31
+ %w(bluepill fail2ban logrotate machine elasticsearch nginx rvm unicorn puma upstart).each do |t|
32
32
  import File.expand_path("../tasks/#{t}.rake", __FILE__)
33
33
  end
@@ -0,0 +1,26 @@
1
+ namespace :fail2ban do
2
+ include Shell
3
+
4
+ desc "Installs the fail2ban configs"
5
+ task :setup do
6
+ on roles(:web) do
7
+ if file_new_or_overwrite?("/etc/fail2ban/jail.conf")
8
+ template "fail2ban-nginx-request-limit-jail.conf.erb", "/tmp/fail2ban_jail"
9
+ sudo "mv /tmp/fail2ban_jail /etc/fail2ban/jail.conf"
10
+ end
11
+ if file_new_or_overwrite?("/etc/fail2ban/filter.d/nginx-req-limit.conf")
12
+ template "fail2ban-nginx-request-limit-jail.conf.erb", "/tmp/fail2ban_req_filter"
13
+ sudo "mv /tmp/fail2ban_req_filter /etc/fail2ban/filter.d/nginx-req-limit.conf"
14
+ end
15
+ end
16
+ end
17
+
18
+ desc "Restart fail2ban"
19
+ task :restart do
20
+ on roles(:web) do
21
+ sudo "service fail2ban restart"
22
+ end
23
+ end
24
+
25
+ after "fail2ban:setup", "fail2ban:restart"
26
+ end
@@ -47,6 +47,7 @@ namespace :machine do
47
47
  invoke "puma:setup" if fetch(:app_server) == "puma"
48
48
  invoke "upstart:setup"
49
49
  invoke "logrotate:setup"
50
+ invoke "fail2ban:setup"
50
51
  invoke "bluepill:setup"
51
52
  end
52
53
  before :setup, "deploy:ensure_folder"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: deploy_mate
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.18.1
4
+ version: 0.18.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tim Adler
@@ -85,6 +85,8 @@ files:
85
85
  - deploy-mate.gemspec
86
86
  - lib/capistrano/README.md
87
87
  - lib/capistrano/configs/application.pill.erb
88
+ - lib/capistrano/configs/fail2ban-nginx-request-limit-filter.conf.erb
89
+ - lib/capistrano/configs/fail2ban-nginx-request-limit-jail.conf.erb
88
90
  - lib/capistrano/configs/logrotate.erb
89
91
  - lib/capistrano/configs/nginx_app.conf.erb
90
92
  - lib/capistrano/configs/nginx_base.conf.erb
@@ -105,6 +107,7 @@ files:
105
107
  - lib/capistrano/scripts/set_defaults.sh
106
108
  - lib/capistrano/tasks/bluepill.rake
107
109
  - lib/capistrano/tasks/elasticsearch.rake
110
+ - lib/capistrano/tasks/fail2ban.rake
108
111
  - lib/capistrano/tasks/logrotate.rake
109
112
  - lib/capistrano/tasks/machine.rake
110
113
  - lib/capistrano/tasks/nginx.rake