# HAProxy backend logging

**URL:** <https://discourse.haproxy.org/t/haproxy-backend-logging/2228>\
**Category:** Help!\
**Created:** [March 11, 2018, 4:32am UTC](https://discourse.haproxy.org/t/haproxy-backend-logging/2228 "2018-03-11T04:32:20Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![senattcs](https://avatars.discourse-cdn.com/v4/letter/s/3bc359/32.png) [@senattcs](https://discourse.haproxy.org/u/senattcs)\
**Post date:** [March 11, 2018, 4:32am UTC](https://discourse.haproxy.org/t/haproxy-backend-logging/2228/1 "2018-03-11T04:32:20Z")

</div>

Is there a way to log the HTTP headers going to a backend? I’m getting HTTP 400 Bad Request from a backend server and I need to figure what headers we are sending towards a backend.

---

<div class="post-metadata">

**Author:** ![lukastribus](https://avatars.discourse-cdn.com/v4/letter/l/7ea924/32.png) [@lukastribus](https://discourse.haproxy.org/u/lukastribus)\
**Post date:** [March 12, 2018, 4:50pm UTC](https://discourse.haproxy.org/t/haproxy-backend-logging/2228/2 "2018-03-12T16:50:06Z")

</div>

You run haproxy in debug mode, but it’s way easier to just run tcpdump and capture it yourself, that will also certainly not be biased, but haproxy may be (if there is a bug).

That’s said if haproxy is rejecting a request, you can use the [show errors](http://cbonte.github.io/haproxy-dconv/1.7/management.html#9.3-show%20errors) command on the admin socket to understand the reason haproxy rejected the request (or response). But that doesn’t seem to be your use-case here.

---

<div class="post-metadata">

**Author:** ![AaronWest](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.haproxy.org/aaronwest/32/164_2.png) [@AaronWest](https://discourse.haproxy.org/u/AaronWest)\
**Post date:** [March 12, 2018, 6:50pm UTC](https://discourse.haproxy.org/t/haproxy-backend-logging/2228/3 "2018-03-12T18:50:44Z")

</div>

Just to add if it helps, I usually use this tcpdump command:

```auto
tcpdump -A -s 10240 'tcp port 80 and (((ip[2:2] - ((ip[0]&0xf)<<2)) - ((tcp[12]&0xf0)>>2)) != 0)' | egrep --line-buffered "^........(GET |HTTP\/|POST |HEAD )|^[A-Za-z0-9-]+: " | sed -r 's/^........(GET |HTTP\/|POST |HEAD )/\n\1/g'

```

---

<div class="post-metadata">

**Author:** ![senattcs](https://avatars.discourse-cdn.com/v4/letter/s/3bc359/32.png) [@senattcs](https://discourse.haproxy.org/u/senattcs)\
**Post date:** [March 14, 2018, 4:33am UTC](https://discourse.haproxy.org/t/haproxy-backend-logging/2228/4 "2018-03-14T04:33:06Z")

</div>

Unfotunately I dont have root access to run TCPDUMP and it’s not HAproxy rejecting the request. one of the HAproxy backend is rejecting the request, so I need to capture the headers going south bound.

when I ran the “show errors” on nc- its always shows as ‘0’.

any other suggestions? Appreciate your help!

---

<div class="post-metadata">

**Author:** ![lukastribus](https://avatars.discourse-cdn.com/v4/letter/l/7ea924/32.png) [@lukastribus](https://discourse.haproxy.org/u/lukastribus)\
**Post date:** [March 14, 2018, 8:14am UTC](https://discourse.haproxy.org/t/haproxy-backend-logging/2228/5 "2018-03-14T08:14:43Z")

</div>

How do you change the haproxy configuration when you are not root?

---

<div class="post-metadata">

**Author:** ![senattcs](https://avatars.discourse-cdn.com/v4/letter/s/3bc359/32.png) [@senattcs](https://discourse.haproxy.org/u/senattcs)\
**Post date:** [March 14, 2018, 5:10pm UTC](https://discourse.haproxy.org/t/haproxy-backend-logging/2228/6 "2018-03-14T17:10:51Z")

</div>

> [@lukastribus](#):
>
> How do you change the haproxy configuration when you are not root?

I’m running HAProxy as non-root

---

<div class="post-metadata">

**Author:** ![lukastribus](https://avatars.discourse-cdn.com/v4/letter/l/7ea924/32.png) [@lukastribus](https://discourse.haproxy.org/u/lukastribus)\
**Post date:** [March 14, 2018, 5:26pm UTC](https://discourse.haproxy.org/t/haproxy-backend-logging/2228/7 "2018-03-14T17:26:23Z")

</div>

Ok, then the only possibility is to run this request through haproxy in debug mode.

---

<div class="post-metadata">

**Author:** ![senattcs](https://avatars.discourse-cdn.com/v4/letter/s/3bc359/32.png) [@senattcs](https://discourse.haproxy.org/u/senattcs)\
**Post date:** [March 14, 2018, 5:38pm UTC](https://discourse.haproxy.org/t/haproxy-backend-logging/2228/8 "2018-03-14T17:38:00Z")

</div>

hmm-when you say HAProxy in debug mode- all I need to add “debug” word in global section? Possible to give a sample please?

---

<div class="post-metadata">

**Author:** ![lukastribus](https://avatars.discourse-cdn.com/v4/letter/l/7ea924/32.png) [@lukastribus](https://discourse.haproxy.org/u/lukastribus)\
**Post date:** [March 14, 2018, 5:45pm UTC](https://discourse.haproxy.org/t/haproxy-backend-logging/2228/9 "2018-03-14T17:45:10Z")

</div>

No, stop haproxy, and start it manually from the command line with the -d argument:

`haproxy -f /path/to/haproxy.cfg -d`

You will then see the entire requests and response in your terminal. Stop haproxy with ctrl-C and start haproxy again via your process manager (or whatever method you use to start haproxy usually).

---

<div class="post-metadata">

**Author:** ![senattcs](https://avatars.discourse-cdn.com/v4/letter/s/3bc359/32.png) [@senattcs](https://discourse.haproxy.org/u/senattcs)\
**Post date:** [March 14, 2018, 7:13pm UTC](https://discourse.haproxy.org/t/haproxy-backend-logging/2228/10 "2018-03-14T19:13:23Z")

</div>

I did that- all I see is incoming headers and the 400 error. here is what Im seeing-

0000004f:http\_frontend.clireq[000b:ffffffff]: POST [https://x.x.x.x:443/Event/Publish/AccountActivityEvent](https://x.x.x.x:443/Event/Publish/AccountActivityEvent) HTTP/1.1  
0000004f:http\_frontend.clihdr[000b:ffffffff]: SOAPAction: “createAccountActivityEvent”  
0000004f:http\_frontend.clihdr[000b:ffffffff]: Content-Type: text/xml;charset=UTF-8  
0000004f:http\_frontend.clihdr[000b:ffffffff]: User-Agent: Jakarta Commons-HttpClient/3.1  
0000004f:http\_frontend.clihdr[000b:ffffffff]: Host:x.x.x.x:443  
0000004f:http\_frontend.clihdr[000b:ffffffff]: Content-Length:1351  
0000004f:AccountActivityEvent.createAccountActivityEvent.srvrep[000b:000d]: HTTP/1.1 400 Bad Request  
0000004f:AccountActivityEvent.createAccountActivityEvent.srvhdr[000b:000d]: Content-Type: text/plain  
0000004f:AccountActivityEvent.createAccountActivityEvent.srvhdr[000b:000d]: Connection: close  
0000004f:AccountActivityEvent.createAccountActivityEvent.srvcls[000b:000d]  
0000004f:AccountActivityEvent.createAccountActivityEvent.clicls[000b:000d]  
0000004f:AccountActivityEvent.createAccountActivityEvent.closed[000b:000d]

---

<div class="post-metadata">

**Author:** ![senattcs](https://avatars.discourse-cdn.com/v4/letter/s/3bc359/32.png) [@senattcs](https://discourse.haproxy.org/u/senattcs)\
**Post date:** [March 15, 2018, 7:08pm UTC](https://discourse.haproxy.org/t/haproxy-backend-logging/2228/11 "2018-03-15T19:08:58Z")

</div>

I relied to your thread yesterday - but for some reason my post is hidden. I started HAP in foreground with “-d”  
and all I could see is following-

0000004f:http\_frontend.clireq[000b:ffffffff]: POST [https://x.x.x.x:443/Event/Publish/AccountActivityEvent](https://x.x.x.x:443/Event/Publish/AccountActivityEvent) HTTP/1.1  
0000004f:http\_frontend.clihdr[000b:ffffffff]: SOAPAction: “createAccountActivityEvent”  
0000004f:http\_frontend.clihdr[000b:ffffffff]: Content-Type: text/xml;charset=UTF-8  
0000004f:http\_frontend.clihdr[000b:ffffffff]: User-Agent: Jakarta Commons-HttpClient/3.1  
0000004f:http\_frontend.clihdr[000b:ffffffff]: Host:x.x.x.x:443  
0000004f:http\_frontend.clihdr[000b:ffffffff]: Content-Length:1351  
0000004f:AccountActivityEvent.createAccountActivityEvent.srvrep[000b:000d]: HTTP/1.1 400 Bad Request  
0000004f:AccountActivityEvent.createAccountActivityEvent.srvhdr[000b:000d]: Content-Type: text/plain  
0000004f:AccountActivityEvent.createAccountActivityEvent.srvhdr[000b:000d]: Connection: close  
0000004f:AccountActivityEvent.createAccountActivityEvent.srvcls[000b:000d]  
0000004f:AccountActivityEvent.createAccountActivityEvent.clicls[000b:000d]  
0000004f:AccountActivityEvent.createAccountActivityEvent.closed[000b:000d]

---

<div class="post-metadata">

**Author:** ![lukastribus](https://avatars.discourse-cdn.com/v4/letter/l/7ea924/32.png) [@lukastribus](https://discourse.haproxy.org/u/lukastribus)\
**Post date:** [March 20, 2018, 3:08pm UTC](https://discourse.haproxy.org/t/haproxy-backend-logging/2228/12 "2018-03-20T15:08:12Z")

</div>

So you got what you needed.

Or do you need help with the actual troubleshooting as well? In that case, please upload the log output to something like pastebin, because the forum will mess with this logs so that it is impossible for me to tell what the forum did and what is really in the original request.

Also share your entire configuration please (replace actual hostnames and IPs, but share everything else).

---

<div class="post-metadata">

**Author:** ![senattcs](https://avatars.discourse-cdn.com/v4/letter/s/3bc359/32.png) [@senattcs](https://discourse.haproxy.org/u/senattcs)\
**Post date:** [March 24, 2018, 5:24pm UTC](https://discourse.haproxy.org/t/haproxy-backend-logging/2228/13 "2018-03-24T17:24:26Z")

</div>

Finally figured out that- there was an extra space in URI sent by client. Removed that extraspace using reqrep
