标签:rsyslog http via add bind 方法 list serve server
HAProxy日志配置HAProxy可以基于rsyslog记录日志到指定的设备
1.修改haproxy配置文件
[root@localhost ~]# vim /etc/haproxy/haproxy.cfg
log 127.0.0.1 local3 info #在全局配置段中配置,定义日志记录级别
2.修改syslog的配置文件
[root@localhost ~]# vim /etc/rsyslog.conf
# Provides UDP syslog reception
$ModLoad imudp #日志传输基于udp所以需要开启
$UDPServerRun 514 #这里两项
local3.* /var/log/haproxy.log
3.重启haproxy和rsyslog服务
[root@localhost ~]# systemctl restart haproxy rsyslog
4.配置HAPronxy
listen web
bind 172.20.27.20:80
mode http
rspadd x-via:\ haproxy
rspdel Server:.*
cookie SERVER-COOKIE insert indirect nocache
log global #配置记录日志
option forwardfor
server web1 192.168.27.21:80 cookie web1 check inter 3000 fall 3 rise 5
server web2 192.168.27.22:80 cookie web2 check inter 3000 fall 3 rise 5
5.通过浏览器访问后,查看日志
[root@localhost ~]# tail -f /var/log/messages
Jun 5 21:04:50 localhost haproxy[23428]: Connect from 172.20.136.96:50376 to 172.20.27.20:80 (web/HTTP)
Jun 5 21:04:50 localhost haproxy[23428]: Connect from 172.20.136.96:50377 to 172.20.27.20:80 (web/HTTP)
haproxy默认的日志过于简单,也可以自定日志进行修改
标签:rsyslog http via add bind 方法 list serve server
原文地址:https://blog.51cto.com/11886307/2406609