我已经设置了一个Lua脚本来处理HAProxy中的请求。我正在使用Core类来记录日志文件中的信息。
这是我的配置文件
sudo nano /etc/haproxy.cfg
global
lua-load /etc/haproxy/route_req.lua
log /dev/log local0
log /dev/log local1 notice
chroot /var/lib/haproxy
stats timeout 30s
user haproxy
group haproxy
daemon
#HAProxy for web servers
frontend web-frontend
bind 10.122.0.2:80
bind 139.59.75.106:80
mode http
use_backend %[lua.routeIP]这是我的route_req.lua文件
local function getIP(txn)
local clientip = txn.f:src()
backend = ""
-- MY CODE GOES HERE
core.log(core.info, "This is an example\n")
return backend
end
core.register_fetches('routeIP', getIP)我没有在日志文件中看到任何日志记录,/var/log/haproxy.log。此外,在/var/log/syslog文件中也没有关于相同的日志记录。
发布于 2022-05-17 20:43:18
确保在您的log global节中包含frontend。
https://stackoverflow.com/questions/72279251
复制相似问题