Forum

GENERAL

HAproxy + hiawatha
25 June 2010, 11:25
Hello,
I am desperate for some help over here. i am trying to configure hiawatha with haproxy ver 1.4.8 server in front of two hiawatha servers. When i start the haproxy daemon response i am getting from hiawatha - 404 not found. log below.
also i would like to mention everything is working when i start apache on my webserver machines, and hiawatha is working on both machines if i use firefox to connect to web sites.


wdtest@wdtest:~$ sudo /usr/sbin/haproxy -f /etc/haproxy/haproxy.cfg -d -p /var/run/haproxy.pid 2>&1 |tee /tmp/haproxy.log
Available polling systems :
sepoll : pref=400, test result OK
epoll : pref=300, test result OK
poll : pref=200, test result OK
select : pref=150, test result OK
Total: 4 (4 usable), will use sepoll.
[WARNING] 175/112859 (5060) : Server load_balanced/wds1 is DOWN, reason: Layer7 wrong status, code: 404, info: "Not Found", check duration: 0ms.
[WARNING] 175/112900 (5060) : Server load_balanced/wds2 is DOWN, reason: Layer7 wrong status, code: 404, info: "Not Found", check duration: 0ms.
[ALERT] 175/112900 (5060) : proxy 'load_balanced' has no server available!

please find hiawatha access log on wds2 below.
192.168.0.232|Fri 25 Jun 2010 11:31:10 +0200|404|173||HEAD /index.html HTTP/1.0


Hiawatha version: 7.3
Operating System: Ubuntu server 10.04
Hugo Leisink
25 June 2010, 15:34
Is an index.html present in the virtual host with hostname 192.168.0.232 or in the default host if such virtual host does not exist?
Zeljko
28 June 2010, 09:36
Yes, index.html is present on both servers wds1 and wds2.

Configuration of wds1:
VirtualHost {
Hostname = 192.168.0.234,wds1
WebsiteRoot = /var/www
...

Configuration of wds2:
VirtualHost {
Hostname = 192.168.0.235,wds2
WebsiteRoot = /var/www
...


Opening http://192.168.0.234/index.html Firefox is fine.
Logfile on wds1 (192.168.0.234):
...
192.168.0.232|Mon 28 Jun 2010 08:59:44 +0200|404|173||HEAD /index.html HTTP/1.0
192.168.0.232|Mon 28 Jun 2010 08:59:46 +0200|404|173||HEAD /index.html HTTP/1.0
192.168.0.232|Mon 28 Jun 2010 08:59:48 +0200|404|173||HEAD /index.html HTTP/1.0
192.168.0.131|Mon 28 Jun 2010 08:59:49 +0200|200|324||GET /index.html HTTP/1.1|Host: 192.168.0.234|User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.2.3) Gecko/20100423 Ubuntu/10.04 (lucid) Firefox/3.6.3|Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8|Accept-Language: en-us,en;q=0.5|Accept-Encoding: gzip,deflate|Accept-Charset: UTF-8,*|Keep-Alive: 115
192.168.0.232|Mon 28 Jun 2010 08:59:50 +0200|404|173||HEAD /index.html HTTP/1.0
...
where 192.168.0.232 is the high availability proxy server haproxy, and 192.168.0.131 is Firefox on my local PC.

In addition, everything works using Apache.
Hugo Leisink
28 June 2010, 10:50
You have a virtualhost with hostname 192.168.0.234 and one with 192.168.0.235. But the IP address in the logfile is 192.168.0.232. For that, no virtual host is defined, so Hiawatha will use the default host. The default host probably doesn't have a index.html file. The log entry for Firefox's request has IP address 192.168.0.131, again a totally different 'hostname'.

It looks like you have to fix the hostname / IP address configuration of your setup.
Zeljko
28 June 2010, 11:32
I am confused. My PC has the IP 192.168.0.131. The Hiawatha webservers are running on both machines 192.168.0.234 and 192.168.0.235.

Again, logfile from Hiawatha on 192.168.0.234:
192.168.0.131|Mon 28 Jun 2010 08:59:49 +0200|200|324||GET /index.html HTTP/1.1|Host: 192.168.0.234|User-Agent: .....

As far as I understand, that line means: "IP 192.168.0.131 requested the file index.html from me, I am hosting 192.168.0.234, so I deliver."

The lines beginning with 192.168.0.232 is the haproxy server on 192.168.0.232, trying to connect to the webserver.
Maybe the problem is caused by haproxy's incomplete requests, which are not telling Hiawatha the hostname.
Hugo Leisink
28 June 2010, 11:37
Oh crap. I'm sorry, you're right. I shouldn't have typed my previous post while doing other stuff at the same time. Yes, the IP at the beginning is of course the IP of the client. Ignore my previous post.

Nevertheless, the HEAD requests don't contain a Host HTTP header, so Hiawatha will use the default host. What I said about a hostname misconfiguration is still the case. What you should do on your two webservers is point your default host to the same directory as your virtual host (the wds[12]).
Zeljko
28 June 2010, 11:39
Yep, solved. That was it.

The correct Hiawatha configuration on the high availability server 192.168.0.235 goes like this:
# DEFAULT WEBSITE
# It is wise to use your IP address as the hostname of the default website
# and give it a blank webpage. By doing so, automated webscanners won't find
# your possible vulnerable website.
#
Hostname = 192.168.0.235
WebsiteRoot = /var/www
StartFile = index.html

VirtualHost {
...


The haproxy server always falls down to checking the default host. On the low-security Apache that behaviour is no problem.

Thanks for your quick replies,
keep up at the good work!

This topic has been closed.