Overview of additional packages: AdditionalPackages

Webserver

Use the WL500g to serve your webpages to the world! Mix dynamic and static content but dont forget to protect you personal pages using a password.

Features

Download

Oleg's custom firmware already contains the http server. It is part of the busybox image and named: busybox_httpd.

Source

The source code can be downloaded here: http://www.busybox.net

Compiling

(Some info on compiling the source should come here...)

Installation

The webserver reads its configuration from /etc/httpd.conf by default. When you change this file and want to save it persistantly you need to use the Flashfs-boot functionality, see: FlashfsBoot.

The syntax of the busybox_httpd command and the httpd.conf file can be found here: HttpConfigurationFileSyntax.

The webserver is not started by default. Add the following line to your /usr/local/init/post-boot script (you might have to create it, see FlashfsBoot)
busybox_httpd -p 8080 -h /mnt/usbfs/webroot

Routing
Port 80 is used by de router' webconfiguration interface, so you can't run the second webserver on this port. But you can configure your router so that the webserver can be accessed through port 80 on you WAN interface. You need to setup portforwarding from port 80 to port 8080 in order to accomplish this.

Add the following lines to your /usr/local/init/post-firewall script:

  iptables -t nat -I PREROUTING -p tcp -d "$2" --dport 80 -j DNAT --to "$2":8080
  iptables -t nat -D PREROUTING -i "$1" -p tcp --dport 80 -j DROP
  iptables -t nat -I PREROUTING -i "$1" -p tcp --dport 8080 -j DROP
  iptables -A INPUT -i "$1" -d "$2" -p tcp --syn --dport 8080 -j ACCEPT

This setup will direct you to the WL500g admin webserver if you use the internal interface, http://my.router and to your own website when you visit: http://my.router:8080. When you visit the external adress, for example, http://wl500g.dyndns.org (or your external IP) you will be redirected to your own webserver. Finally, access is blocked for direct access on port 8080 from WAN.

Dynamic pages
The webserver can handle cgi-bin scripts as well. With cgi-bin scripts you can create dynamic webpages and are stored in a subdirectory of your webroot directory which is called cgi-bin. So if your webroot is /mnt/usbfs/wwwroot then your cgi-bin directory is /mnt/usbfs/wwwroot/cgi-bin. Scripts can also be placed in subdirectories of the ./cgi-bin directory.

The webserver can only handle Bash scripts. These Bash scripts need to have executable rights which can be set using the following command: chmod +x scriptname. Once the script is copied to the cgi-bin directory you can access it by typing the following command in the address toolbar of your browser: http://my.router/cgi-bin/scriptname.

Note: If the script has no executable rights or has syntax errors then the webserver will return error 404 (page not found).

Below is an example of a Bash script:
HttpScriptSystemInfo It shows some interesting info from your router.

Related links

Topics on Chupa.nl Forum:

Elsewhere:

Known problems