Lighttpd
- Ankur Desa
- May 23, 2017
- 2 min read
There are some of us who are running DDWRT on their routers and like me, would want to run basic webservers on the routers. The thing with running webserver on the router, at the the most important thing for me, is that they should be lightweight. should not take up too many resources.
Here is a simple webserver that you could install on the router using DDWRT. i chose this because it serves my purpose and i like it light, simple to configure.
Below is the small guide for those who really want to have a webserver to host webpages. For more complicated stuff, you would need to look it up on the internet.
Lightttpd Tutorial
Want to run a fast, low-resource server for static content? It's easy. Create a text file named lighttpd.conf with the following content:
server.document-root = "/var/www/servers/www.example.org/pages/"
server.port = 3000
mimetype.assign = (
".html" => "text/html",
".txt" => "text/plain",
".jpg" => "image/jpeg",
".png" => "image/png"
)
lighttpd will listen on TCP port 3000 and bind to all interfaces by default. The few important MIME types are assigned and the document root (the base directory that is used for all requests) is set. The files in the document root have to be readable by the user starting the web server.
First, check that your configuration is ok:
$ lighttpd -t -f lighttpd.conf
Now start the server for testing:
$ lighttpd -D -f lighttpd.conf
and point your browser to http://127.0.0.1:3000/
To stop the server, return to the command prompt and press ctrl-c.
A real daemon
Next you should familiarize yourself with some settings necessary for your server's security:
server.document-root = "/var/www/servers/www.example.org/pages/"
server.port = 80
server.username = "www"
server.groupname = "www"
mimetype.assign = (
".html" => "text/html",
".txt" => "text/plain",
".jpg" => "image/jpeg",
".png" => "image/png"
)
static-file.exclude-extensions = ( ".fcgi", ".php", ".rb", "~", ".inc" )
index-file.names = ( "index.html" )
Now the web server is listening on port 80, the default for HTTP traffic, and will switch to the user www and the group www. The server has to be started as root to take control of port 80, but it's not necessary or a good idea to continue running as root after port acquisition, so the server switches to user www.
Lastly, access to view the contents of some types of files is forbidden as they are used for generating dynamic content. Requests directly to a directory are rewritten to the index.html file in that directory.
Assuming you have already created the /etc/init.d/lighttpd service as described in "Init Script" section of InstallFromSource, place the config file in /etc/lighttpd/lighttpd.conf and start the server with:
# /etc/init.d/lighttpd start
To stop it use:
# /etc/init.d/lighttpd stop
Source - Lighttpd
Commenti