Amaury Denoyelle | 94fd133 | 2021-05-12 10:51:22 +0200 | [diff] [blame] | 1 | varnishtest "stick table: src_conn_rate" |
| 2 | feature ignore_unknown_macro |
| 3 | |
| 4 | haproxy h0 -conf { |
| 5 | defaults |
| 6 | mode http |
| 7 | timeout connect 5s |
| 8 | timeout client 5s |
| 9 | timeout server 5s |
| 10 | |
| 11 | listen li |
| 12 | ${no-htx} option http-use-htx |
| 13 | bind "fd@${fe1}" |
| 14 | http-request track-sc0 src table conn_rate_table |
| 15 | http-request deny if { src_conn_rate(conn_rate_table) gt 3 } |
| 16 | http-request return status 200 |
| 17 | |
| 18 | backend conn_rate_table |
| 19 | stick-table type ip size 1m expire 1m store conn_rate(1m) |
| 20 | } -start |
| 21 | |
| 22 | client c0 -connect ${h0_fe1_addr}:${h0_fe1_port} { |
| 23 | txreq |
| 24 | rxresp |
| 25 | expect resp.status == 200 |
| 26 | } -run |
| 27 | |
| 28 | client c1 -connect ${h0_fe1_addr}:${h0_fe1_port} { |
| 29 | txreq |
| 30 | rxresp |
| 31 | expect resp.status == 200 |
| 32 | } -run |
| 33 | |
| 34 | client c2 -connect ${h0_fe1_addr}:${h0_fe1_port} { |
| 35 | txreq |
| 36 | rxresp |
| 37 | expect resp.status == 200 |
| 38 | } -run |
| 39 | |
| 40 | client c3 -connect ${h0_fe1_addr}:${h0_fe1_port} { |
| 41 | txreq |
| 42 | rxresp |
| 43 | expect resp.status == 403 |
| 44 | } -run |