I want to use GoAccess with Haproxy which works as reverse proxy and load balancer.

My goal is to create a custom log format which will be looking exactly like apache2 (compatible with default goaccess settings).

so far I did

capture request header Referrer len 64

capture request header Content-Length len 10

capture request header User-Agent len 64

log-format %si:%sp\ %ci\ -\ -\ [%t]\ "%r"\ %ST\ %B\ "%%Referrer"\ "%%User-Agent"

My haproxy version is HA-Proxy version 1.5.14 2015/07/02

I dont know how to extract referrer and user agent from captured request. I cant find anything usefull about Custom Log Format in manual.


I figure out %hrl is a string list of the captured request headers. Is it possible to extract values by key or index?

1 Answer 1


I solved this by creating my own log format:


time-format %H:%M:%S

date-format %d/%b/%Y

log-format %^ %^ %^ %^ %^ %^ %h [%d:%t.%^] "%r" %s %b "{%R|%u}"

# %^ - skipped token
# %h - user ip
# %d - date-format
# %t - time-format
# %r - request e.g. GET /something
# %s - server status code
# %b - data response length
# %R - referer - very important if you want to know where your users come from
# %u - user agent

# There is so many skipped tokens because my haproxy put some extra information in every line or rsyslog(?)
# Sample line:
# Mar 22 09:09:06 server haproxy[PID]: [22/Mar/2016:09:08:56.989] "POST /UIDL/?v-uiId=0 HTTP/1.1" 200 334 "{https://www.referer.com/|Mozilla/5.0 (Linux; Android 4.4.4; GT-I9060I Build/KTU84P) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/47.0.2526.83 Mobile Saf}"


capture request header Referer len 128
capture request header User-Agent len 128

log-format %si:%sp\ %ci\ [%t]\ "%r"\ %ST\ %B\ "%hr"

# %si - your server ip - very usefull if you have multiple application
# %sp - your server port
# %ci - user ip
# %t  - datetime in haproxy format
# %r  - request
# %ST - status code
# %B  - data reponse length
# %hr - captured headers separated by "|" (Referer|User-Agent)
  • In haproxy I needed to escape " also to work. Like this: log-format "%si:%sp\ %ci\ [%t]\ \"%r\"\ %ST\ %B\ \"%hr\"" (Also - many thanks for sharing!)
    – YoniXw
    Aug 24, 2021 at 11:20

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .