Portal Home > Knowledgebase > Articles Database > Apache's ProxyPreserveHost is not preserving the host?


Apache's ProxyPreserveHost is not preserving the host?




Posted by realrena, 12-31-2007, 06:06 AM
Hi all, First of all, I would like to thank you for reading this thread. OK here goes my problem. I just installed lighttpd as a proxy for apache to serve static content. What I have in apache under the Virtualhost is the following: But somehow, when I read the logs inside /var/log/lighttpd, all I can see is that 127.0.0.1 as the host. Can anyone tell me what is wrong??

Posted by Bilco105, 12-31-2007, 07:23 AM
Do you have a copy of an access request? I take it the actual client requesting IP is being recorded correctly? What version of Apache are you running, as there was a bug with similiar symptoms in Apache 2.0.52 I think.

Posted by realrena, 12-31-2007, 08:41 AM
Hi Bilco105, 1) Below is what i see in /var/log/lighttpd/access.log 127.0.0.1 is exactly what the log has recorded. 2) I'm running Apache 2.2.3 + Lighttpd 1.4.18

Posted by wKkaY, 01-01-2008, 05:44 AM
Lighttpd will set an X-Forwarded-For header that contains the client IP. To make Apache assume the client IP from that header, you need to use modules like mod_rpaf or mod_extract_forwarded. Personally I use the former.

Posted by realrena, 01-02-2008, 06:14 AM
Hmm somehow it's not working.. Still getting 127.0.0.1 in my logs

Posted by Bilco105, 01-02-2008, 06:18 AM
I'm slightly confused by your setup. You say you're using lighty to proxy requests through to Apache. However, your config shows you also using Apache to proxy requests through to something on port 1234. Is this done for a reason?. I'm trying to understand why you have multiple levels of proxying.

Posted by wKkaY, 01-02-2008, 06:59 AM
You're right, Bilco105. I misread the first post (didn't see the part where he was reading off /var/log/lighttpd) and thought he was proxying Apache with lighttpd.

Posted by Bilco105, 01-02-2008, 07:55 AM
I still don't get why you would have Apache proxy through to lighttpd. I would have thought the reverse would be better, what with lighty being a lot more lightweight and robust for this type of setup.

Posted by realrena, 01-02-2008, 05:57 PM
I think I made a mistake in the Apache's ProxyPass directives. I guess I should take out this line Apache's my main, and proxy some of the large static files to Lighttpd. The reason for this (Apache as main, Lighttpd as proxy) is because I have some custom written modules for apache, and it'll take alot of time to rewrite them to lighttpd. Last edited by realrena; 01-02-2008 at 06:02 PM.

Posted by Bilco105, 01-02-2008, 09:04 PM
If you are using lighttpd as a proxy, then you don't need any of the proxy directives in your apache configuration. Lighttpd forwards requests with the X-Forwarded-For header, which Apache doesn't process. You'll need to install mod_rpaf and configure it with the IP's of your proxy server(s). This will extract the IP/Host from the forwarded-for address and change the remote address of the client.



Was this answer helpful?

Add to Favourites Add to Favourites    Print this Article Print this Article

Also Read
arabic characters (Views: 594)
ionCube upgrade (Views: 2088)