Log to different files with different backends in ONE frontend


#1

A short description of the setup:

I have two serverfarms which differs in name (server1.domain and server2.domain) but shares the same frontend (with ssl certificate and same port) …
So the traffic is routed to the backends with

frontend incoming
bind *:443 ssl crt /usr/local/etc/haproxy/cert/server.pem
mode http

Use backend “backend_linux” for “linux.” host.

Use backend “backend_windows” for “windows.” host.

acl host_linux   hdr_beg(host) -i linux.
acl host_windows hdr_beg(host) -i windows.

use_backend backend_linux if host_linux
use_backend backend_windows  if host_windows
default_backend backend_linux

Want I now want to have is a different logfile (using rsyslog) for each server-farm… like

log 127.0.0.1 local1 debug if host_linux
log 127.0.0.1 local2 debug if host_windows
(this is NOT possible in the current version)

BUT is there any other solution for that problem except to splitt the incoming traffic to two frontends ?


#2

Logging configuration is not necessarily global, you can also configure it per section, however, frontend logging configuration will log the connection, backend logging is only used for server status changes.

Meaning, you can log connections to different syslog servers based on different frontends, however, in this content-switching configuration it is not trivially possible.

A reiteration through another layer frontend/backend layer is possible, so that you have 2 second level frontends that are dedicated to either linux or windows host and can therefor have distinct logging configurations.