Monday, July 18, 2011

Simple Busybox HTTP Server

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.


  1. (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.

  2. Configure busybox httpd
    The OpenWrt's busybox is installed if you followed the previous post about cron. This busybox provides more features than the DD-WRT one, including a small web server.

    To launch it, run:
  3. /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. 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

1 comments:

Thank You For This Post ! Your Post Is Veri Nice ! Please keep it up !
We provide full free 100 % tested flash file that you can download at no cost without any risk.
Firmware Download is one of the best website which provide free android
Free Firmware Download
There Are Many And More Brand

Post a Comment