2

I'm using HAP on and off for a bit now and now I'm trying confgure DDoS protection per frontend, to block a connection for 5 mints, if it receives more than 200 requests per second from the same source IP, taking the fact into account that mutiple source-ips can/will be used to launch the attack. I looked into various blogposts and posts in the Internet and more I see I get more confused about the correct counfig that I need to have for my purpose.

Below are the all the configurations that I have collected so far:

backend ip_rates_abuse
  stick-table type ip size 200k expire 5m store gpc0,conn_cur,conn_rate(10s),http_req_rate(10s),http_err_rate(10s)

frontend fe_dev_mydomain_com
  .....
  ## ----- TCP Layer DDoS protection ------------ ##
  timeout       tarpit 15s
  tcp-request   inspect-delay 5s
  #
  tcp-request   content reject if { src_conn_rate(ip_rates_abuse) ge 200 }
  tcp-request   content reject if { src_conn_cur(ip_rates_abuse) ge 500 }
  tcp-request   content reject if { src_get_gpc0(ip_rates_abuse) gt 0 }
  tcp-request   session track-sc0 src table ip_rates_abuse
  #
  ## ----- Application Layer DDoS protection ------------ ##
  acl           too_many_reqs sc_http_req_rate(0) gt 200
  http-request  track-sc1 src table ip_rates_abuse
  http-request  set-var(txn.ratelimited) str(RATE-LIMITED) if too_many_reqs
  http-request  capture var(txn.ratelimited) len 12
  http-request  deny deny_status 429 if too_many_reqs
  .....
  use_backend   be_waf if no_tarpit || tarpit_max_capacity

and then in the backend:

backend be_waf
  acl          too_many_clicks sc1_http_req_rate gt 200
  acl          mark_as_abuser sc0_inc_gpc0(ip_rates_abuse) gt 0
  tcp-request  content track-sc1 src table ip_rates_abuse
  tcp-request  content reject if too_many_clicks mark_as_abuser
  .....

I'm pretty sure I didn't understand a number of things but did I do it right? Looks like a bit overdoing to me and seems not working either. Can anyone suggest me the minimum config that I should have to achieve my goal pls?

-S

MacUsers
  • 469
  • 2
  • 7
  • 13

0 Answers0