Excerpt from cfg
Backend1
mode http
acl is-error res.hdr(status) 403
http-request track-sc2 src table error-count
http-response sc-inc-gpc0(2) if is-error
option httpchk
balance static-rr
server serverA [serverip-here] check inter 5s downinter 4s maxconn 4000
server serverB [serverip-here] check inter 5s downinter 4s maxconn 4000
backend error-count
stick-table type ip size 1m expire 3m store gpc0
RESULT after I force a 403 error on the browser:
# table: error-count, type: ip, size:1048576, used:1
0x562d0383ccc8: key=IPdisplays-here use=0 exp=173781 gpc0=0
I can see the IP is being tracked and expiration is there no problem, but I can't get gpc0 to update in the stick table. It remains 0.
I've tried all kinds of anonymous and other ACLs and table type string. No luck. Google has nothing. Any ideas are appreciated.
Thanks!
In HTTP, there is not a standard response header called
status
, so this ACL will never match:There is, however, a layer 7 fetch for
status
:I would suggest that this is what you intended:
...or if you prefer explicit comparison expressions, specify an integer match:
The
status
fetch is available in all versions of HAProxy, back to at least 1.5 and probably earlier.I’m not sure that you can increment a sticky counter in the response that is tracked in the request. There’s a similar http-response track-sc2, but I don’t think they cross over.
https://www.haproxy.com/documentation/hapee/1-9r1/onepage/#4.2-http-response%20track-sc0
I am doing something very similar. I am not sure why mine works and yours doesn't. I am definitely incrementing a counter in the response that is tracked in the request. And I do see gpc0 increment in my setup. One possible difference: my sc manipulations are in the frontend. Also, I am using sc0 rather than sc2. I shouldn't think either of these would matter. I am running 1.8.8. My cfg excerpts:
In FE:
BE stick-table:
backend Penalty_Box
If you have managed to get your config working, I would sure like to know what you had to do.