Reference
set table
Add or update a record in a stick table.
Description Jump to heading
Use set table to add or create a record in a stick table, typically to flag a client manually and then block them.
Examples Jump to heading
Consider this real-world example that uses a stick-table to track clients that exceed a rate limit and bans clients that exceed the limit three times:
haproxy
haproxy
- 
Use show tablewith the name of the table to display the records in that table.nixecho "show table fe_main" | \sudo socat stdio tcp4-connect:127.0.0.1:9999nixecho "show table fe_main" | \sudo socat stdio tcp4-connect:127.0.0.1:9999outputtext# table: fe_main, type: ip, size:102400, used:10x5641b364f7e8: key=192.168.50.19 use=0 exp=86398242 gpt0=0 gpc0=3 http_req_rate(5000)=50x5641b364f7e8: key=192.168.50.24 use=0 exp=86398220 gpt0=0 gpc0=1 http_req_rate(5000)=50x5641b364f7e8: key=192.168.50.30 use=0 exp=86398250 gpt0=0 gpc0=0 http_req_rate(5000)=5outputtext# table: fe_main, type: ip, size:102400, used:10x5641b364f7e8: key=192.168.50.19 use=0 exp=86398242 gpt0=0 gpc0=3 http_req_rate(5000)=50x5641b364f7e8: key=192.168.50.24 use=0 exp=86398220 gpt0=0 gpc0=1 http_req_rate(5000)=50x5641b364f7e8: key=192.168.50.30 use=0 exp=86398250 gpt0=0 gpc0=0 http_req_rate(5000)=5Here, it lists records in the table fe_main.
- 
Use set tableto manually set thegpt0counter to 1 and thegpc0counter to 3 for the client with the IP address192.168.50.30.Prefix each counter that you want to set with data:nixecho "set table fe_main key 192.168.50.30 data.gpt0 1 data.gpc0 3" | \sudo socat stdio tcp4-connect:127.0.0.1:9999nixecho "set table fe_main key 192.168.50.30 data.gpt0 1 data.gpc0 3" | \sudo socat stdio tcp4-connect:127.0.0.1:9999
Tip
Available since HAProxy 3.2 and HAProxy Enterprise 3.2r1: for stick-table entires where data is an array, use [] to access a specific index in the array, for example, data.gpt[1].
See also Jump to heading
Do you have any suggestions on how we can improve the content of this page?