Archive for December 2009

Apache modules : the power of ( II )

It’s been a long time ago since my last post here.  Maybe 2010 will give me much more energy to continue sharing stories of a Desperate House Geek.  By the way, I’ve been struggling against a strange behaviour of an Apache Server in front of an application server, with lines of logs like this :

[warn] [client 10.240.xxx.yyy] proxy: no HTTP 0.9 request (with no host line) on incoming request and preserve host set forcing hostname to be my.server.net for uri /

This is due to our monitoring servers with frequent requests to test if the application is Up or Down (mainly, if the Apache is responding)

Googling around landed me in sparse and rare pages about the problem. However, the source code of mod_proxy as well as the error message itself gave me the hint : trying to add the probably missing request header before the request is getting passed to mod_proxy, but only if the incoming request originated from the monitoring robot (10.240.XXX.YYY). Here comes in play the power of Apache with its handy modules mod_headers and mod_setenvif.  Here we go :


SetEnvIf  Remote_Addr  "10\.240\.xxx\.(yyy|zzz)" __ROBOT__
RequestHeader set Host "my.server.net" env=__ROBOT__

It solved the problem.