Skip to content

Instantly share code, notes, and snippets.

@haproxytechblog
Last active November 30, 2022 21:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save haproxytechblog/6e8f7f5b08f2f7bf9c2d8e6fa9e6e715 to your computer and use it in GitHub Desktop.
Save haproxytechblog/6e8f7f5b08f2f7bf9c2d8e6fa9e6e715 to your computer and use it in GitHub Desktop.
Announcing HAProxy 2.7
peers mypeers
bind 0.0.0.0:10000
shards 2
server lb1
server peer1 192.168.56.40:10000 shard 1
server peer2 192.168.56.41:10000 shard 2
table rates type binary len 20 size 100k expire 10s store http_req_rate(10s)
-- script arguments are put into variable 'args'
local args = table.pack(...)
local arg1 = args[1] -- returns 'hello'
local arg2 = args[2] -- returns 123
-- this function prints the arguments when
-- 'http-request lua.log-args' is called
local function log_args(txn)
core.Info(arg1)
core.Info(arg2)
end
core.register_action("log-args", {"http-req"}, log_args, 0)
global
lua-load /path/to/script.lua "hello" 123
frontend mysite
bind :80
default_backend servers
# call the action
http-request lua.log-args
$ echo "reload" | sudo socat -t300 /run/haproxy-master.sock -
Success=1
--
[NOTICE] (2495) : New worker (2546) forked
[NOTICE] (2495) : Loading success.
[NOTICE] (2495) : haproxy version is 2.7
[NOTICE] (2495) : path to executable is /usr/sbin/haproxy
[WARNING] (2495) : Former worker (2538) exited with code 0 (Exit)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment