Hello Haproxians.
I need your help.
I have a Haproxy server balancing between 2 IIS on the back, consuming webservices. And when I try to do a Layer7 check it always return a 500 error code. Can anyone help me on this?
Here are the details:
This is the wrong check:
listen KMAGENTO-SMART-CHECK
bind *:7777
#option httpchk POST /Kliper.asmx HTTP/1.1\nContent-Type:\ text/xml\n<?xml\ version="1.0"\ encoding="UTF-8"?><soapenv:Envelope\ xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"\ xmlns:tem="http://tempuri.org/"><soapenv:Header\ /><soapenv:Body><tem:Flush\ /></soapenv:Body></soapenv:Envelope>
option httpchk
# http-check send meth POST uri /Kliper.asmx hdr Content-Type: text/xml body {<soapenv:Header\ /><soapenv:Body><tem:Flush\ /></soapenv:Body></soapenv:Envelope>}
http-check send meth POST uri /Kliper.asmx hdr Content-Type: text/xml body {<soapenv:Envelope\ xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"\ xmlns:tem="http://tempuri.org/"><soapenv:Header/><soapenv:Body><tem:Flush/></soapenv:Body></soapenv:Envelope>}
server pluton-bkp1-MAGENTO 192.168.10.21:9091 check http
server pluton-bkp2-MAGENTO 192.168.10.166:9091 check http
and here’s the cfg file: https://gofile.io/d/8PkHIU
Please help.
Thanks a lot.
This configuration does not even pass the config check: there is no http
keyword on the server line.
Another error that I can certainly spot is the header configuration of the check, its hdr , without the colon (it’s not an entire http header line your specifying, but argument 1 is the headername, argument 2 is it’s value), so:
wrong:
hdr Content-Type: text/xml
correct:
hdr Content-Type text/xml
If this is not it, please provide the actual configuration you are running as well as a full capture of the health check traffic (something like tcpdump -pns0 -w healthcheck.cap tcp port 9091
).
yeah, the http
keyword was a test, but I remove it now and just let the check
.
I also removed the colon, and the result is the same:
tcpdump in: https://gofile.io/d/ERrjqM
I also change the input XML:
http-check send meth POST uri /Kliper.asmx hdr Content-Type text/xml body <?xml\ version="1.0"\ encoding="UTF-8"?><soapenv:Envelope\ xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"\ xmlns:tem="http://tempuri.org/"><soapenv:Header/><soapenv:Body><tem:EnabledSite/></soapenv:Body></soapenv:Envelope>
After looking at the tcpdump, I think that maybe is the content-length or something in the header that’s causing the conflict.
Thanks a lot.
No, content length and headers are looking good.
Look at the server error message:
Server was unable to process request. ---> '1.0' is an unexpected token. The expected token is '"' or '''. Line 1, position 15
And the request:
<?xml version=1.0 encoding=UTF-8?><soapenv:Envelope xmlns:soapenv=http://schemas.xmlsoap.org/soap/envelope/ xmlns:tem=http://tempuri.org/><soapenv:Header/><soapenv:Body><tem:EnabledSite/></soapenv:Body></soapenv:Envelope>
Haproxy eats the quotes here, which is why it’s sending bogus XML the server rejects.
You will have to escape the double quotes as well (just like you are already escaping spaces).
So something like this?
http-check send meth POST uri /Kliper.asmx hdr Content-Type text/xml body <?xml\ version=\"1.0\"\ encoding=\"UTF-8\"?><soapenv:Envelope\ xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\"\ xmlns:tem=\"http://tempuri.org/\"><soapenv:Header/><soapenv:Body><tem:EnabledSite/></soapenv:Body></soapenv:Envelope>
Man, I don’t know who you are, but I love you.
That worked!!!
Thanks a lot!
HTTP/1.1 200 OK
Cache-Control: private, max-age=0
Content-Type: text/xml; charset=utf-8
Server: Microsoft-IIS/7.5
X-AspNet-Version: 2.0.50727
X-Powered-By: ASP.NET
Date: Mon, 12 Oct 2020 20:24:30 GMT
Connection: close
Content-Length: 448
I owe you a beer or something. It’s gonna be documented now.
1 Like