lighttpd + mod_proxy trick on OpenWRT

Okay, looks like I’m somewhat back after a (very) nasty crash of an raid mirror. Looks like 1Tb WD + 1Tb seagate decided to die together at (nearly) the same time after roughly 19000 hours of operation (according to smart). Luckily smartd detected all those reallocates and ‘runtime bad blocks’ at the very time they appeared, giving me time to order the replacements. However, I decided to completely reconfig the server, so I got quite a few days of downtime. But hey, I’m not google, so who cares?. And 5-year old apache2 config with over 1k lines, that had a chance to work under FreeBSD, Debian, Agilia was just looking to ugly. Even I couldn’t make sense of some older parts of it.
Anyways, I also upgraded the router, now stuffed with OpenWRT+lighttpd to do the dirty work, and I want to quickly describe a small trick I used.
Basically I wanted luci to be avaliable on a subdomain, e.g. router.myhost.net, while all queries to hyhost.net, anythingelse.myhost.net would get forwarded to a http server behind the network.
To do so, you’ll need mod_proxy for your lighty, and something like that. In this fashion, everything not directed to wrt.myhost.net will get to a server behind the router.

$HTTP["host"] != "wrt.myhost.net" {
 proxy.server = ( "" =>
   (( 
   "host" => "192.168.0.7", #web server ip in the lan
   "port" => 80
   ))
 )  
}

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.