By default DD-WRT runs its own http server(/usr/sbin/httpd), providing web management interface to configure the router. The server is highly integrated and hard to reuse for our own contents. If you just want to host some web pages without CGI support, the httpd server in busybox is a good alternative.
- (Optional)Move DD-WRT's web admin to another port
The best way to do so is changing a nvram value as described here.
So login the router and run
nvram set http_lanport=88
nvram commit
Then after rebooting, the new port will be 88 and you can access the web admin at http://router_ip:88/. Everything should work just as before including firmware upgrade. - Configure busybox httpd
The OpenWrt's busybox is installed if you followed the previous post. This busybox provides more features than the DD-WRT one, including a small web server. To launch it, run - Run it as service
Create file /opt/etc/init.d/httpd
source /mnt/root/.profile
/opt/usr/sbin/httpe -p 80 -c /opt/etc/httpd.conf -h /opt/www
And run
chmod a+x /opt/etc/init.d/httpd
ln -sf /opt/etc/init.d/httpd /opt/etc/init.d/S20httpd
/opt/usr/sbin/httpd -p 80 -c /opt/etc/httpd.conf -h /opt/www
the server(/opt/usr/sbin/httpd) will listen port 80(-p 80) with configuration file /opt/etc/httpd.conf(-c /opt/etc/httpd.conf) and use /opt/www as home folder(-h /opt/www).
Everything looks good, except, both our http server and dd-wrt's are called httpd. This will be a problem as DD-WRT will kill and restart the httpd service when applying some settings. If that ever happens, our httpd service will be terminated unexpectedly. So let's change the service name.
Here is (another) dirty hack but works for me. Log in PuTTY and run:
cp /opt/bin/busybox /opt/bin/busybox.orig
cp /opt/bin/busybox /tmp/busybox
sed -i 's/httpd$/httpe/g' /tmp/busybox
cp /tmp/busybox /opt/bin/busybox
ln -s /opt/bin/busybox /opt/usr/sbin/httpe
So now we have changed the name of busybox's http server from httpd to httpe. If it's messed up, restore the old busybox:
/bin/cp /opt/bin/busybox.orig /opt/bin/busybox
4 comments:
ok - got this to work, despite the fact that the start command gives an error:
/opt/usr/sbin/httpe: invalid option --cc
but then almost everything in the configuration file is commented out anyway.
next:
- how do i get it to show index.html by default, or if none exists, showing a directory listing instead?
ok - now that i've played with it a bit more - it doesn't work in the harsh real-world-out-there, at least not for serving mp4 media files.
namely - if a browser aborts a download in the middle, the router goes to hiccup mode with high CPU usage and stops web-serving.
only a reboot will cure it. this, obviously, is unacceptable.
i guess i'll be looking at lighttpd next.
maybe it's because I'm running a different version of busybox (1.15.3), but it didn't come with the link to httpd, and when I create the link following the above directions to use httpe it tells me that the applet doesn't exist.
Any ideas on what to do to get it working?
Thanks!
To answer my own question about busybox...
With the latest version of OpenWRT (BackFire) the http functionality isn't built into busybox.
I grabbed the newest build of busybox from Kamikaze and was able to get it working!
Thanks for the great writeups!
Post a Comment