I have enabled “option httplog” in the default section, and my haproxy config example is like this:
global
maxconn 1048576
stats socket /var/run/haproxy-admin.sock mode 660 level admin expose-fd listeners
stats timeout 30s
pidfile /var/run/haproxy.pid
log 127.0.0.1 local0
max-spread-checks 60s
#hard-stop-after 60s
master-worker no-exit-on-failure
#daemon
#nbproc 1
#stats bind-process 1
#cpu-map 1 0
nbthread 2
resolvers mydns
nameserver dns1 127.0.0.11:53
resolve_retries 3
timeout retry 1s
hold other 10s
hold refused 10s
hold nx 10s
hold timeout 10s
hold valid 10s
defaults
mode http
maxconn 1048576
balance roundrobin
timeout connect 5000ms
timeout client 65000ms
timeout server 65000ms
#timeout http-request 65000ms
timeout tunnel 3600s
timeout check 5s
option httplog
option dontlognull
option http-server-close
option abortonclose
option log-health-checks
log global
log-format %ci:%cp\ [%t]\ %Tr\ %s\ %ST\ %B\ %hr\ %hs\ %H\ %{+Q}r
# If sending a request to one server fails, try to send it to another, 3 times
# before aborting the request
retries 3
#http-reuse safe
option forwardfor
# Do not enforce session affinity (i.e., an HTTP session can be served by
# any Mongrel, not just the one that started the session
option redispatch
no option checkcache
option accept-invalid-http-response
option accept-invalid-http-request
default-server init-addr last,libc,none
listen stats
bind *:1936
stats enable
stats hide-version
stats realm Haproxy\ Statistics
stats uri /haproxy?stats
stats auth admin:admin
frontend name_resolver_http
bind *:80
errorfile 503 /usr/local/etc/haproxy/errors/503.http
capture request header Host len 80
monitor-uri /haproxy-monitor
acl is_websocket hdr(Upgrade) -i WebSocket
frontend name_resolver_https
bind *:443 ssl crt /usr/local/etc/certs/ alpn h2,http/1.1
reqadd X-Forwarded-Proto:\ https
errorfile 503 /usr/local/etc/haproxy/errors/503.http
capture request header Host len 80
monitor-uri /haproxy-monitor
acl is_websocket hdr(Upgrade) -i WebSocket
And my scenario is:
application client -> haproxy -> application server;
but the haproxy instance response its log (not the application server response message) to the application client occasionally.