fantini.name

just wasting bandwidth...

fantini.name

site

This is a static dsl website and is hosted on a Linksys NSLU2 running at my place. The decision to host it at my home on such a “minimalistic” hardware brought many issues on the table. This section describes how I dealt with such issues and finally managed to set my site up.

Table of Contents

  • The Web Host
  • The Web Server(webserver.html)
  • A DSL Webserver(dslwebserver.html)
  • A Static Website
  • Site Deployment

The Web Host

The hardware that is serving these pages is a debian slug. Here you can read how I tweaked my Linksys NSLU2 to run a full Debian OS (i.e. how I set up my debian slug). This is the base platform on which I then installed all the other software needed to run this site.

The Web Server

When I think of a webserver, the first word that comes to my mind is Apache. But in my previous attempt to use the slug as a web host I had realized that Apache was too resource demanding (mostly memory demanding) for this small device. So I googled around and found out what could have been an alternative: lighttpd. On its official website I read that lighttpd aims to reduce the memory footprint and optimize the cpu-load, while focusing on speed and security. Plus, it is really widely used, even by websites that get some million hits a day (like Wikipedia and YouTube, just to name a couple). So I decided to give it a shot. And this turned out to be a great idea: with all the services up and running (including lighttpd), my slug has a memory usage of about 11-13Mb, which is exactly half the memory usage it had on my first attempt with Apache. And still, lighttpd is flexible, easy to configure, and really fast. Just perfect for my needs!

Installing lighttpd on Debian was as simple as:

aptitude install lighttpd lighttpd-doc

After that, the configuration file is deployed in /etc/lighttpd/lighttpd.conf, but I did not need to change anything in the configuration to have my webserver up and running.

A DSL Webserver

Running a webserver at home through a DSL connection raises a few issues. All the details on this subject are explained Here.

Configuring NAT

After installing and configuring my webserver I had to figure out how to make it reachable from the Internet. In fact, when using a DSL connection to connect to the Internet, the router is usually the only host with a public IP address. To work around this issue, almost every DSL router has a functionality called Network Address Translation (NAT), which I had to configure to make my web host accessible from the Internet.

The NAT configuration procedure can be very different depending on the make and model of your router. By enabling NAT, your router will modify address information in packet that transit across the router itself in order to “hide” the fact that they were sent to (or came from) another host. Configuring NAT on your router consists in defining one or more forwarding rules. Usually through such rules you can decide that a request incoming on a particular port on your router should be forwarded to a certain device inside your local network. So if you need to NAT a webserver you will probably want to forward connections incoming on port 80 of your router.

My own device, as the vast majority of (modern) DSL router, provides a web configuration tool (to make configuration simpler). So I just logged into my router’s configuration page with a web browser, enabled NAT and defined a NAT rule to forward any incoming connection on port 80 to my web host. Then I also had to disable my router’s built-in firewall on the same port. That’s it.

When you complete this step, you should be able to access your web server from the Internet. To check if everything is ok you can type your router’s public IP address into a web browser on a computer (that of course has to be outside your local network): by doing this, you should be able to access your web server’s default homepage.

Dynamic DNS Services

Another problem I faced was the fact that my DSL connection has a dynamic public IP address (as most of the cheap DSL connections here in Italy). In other words, every time my DSL router connects to my provider, it is assigned a new public IP address with which the router (and thus the web server behind it) will be reachable through the Internet. This implies that if I wanted to keep my domain name associated with my public IP address, I would need to manually update the DNS entries for my domain every time my router reconnected to the Internet. And anyway, changes to DNS entries usally take a while to propagate to the other DNS servers. Unacceptable. The solution to this issue is to subscribe to a dynamic DNS service.

The basic idea behind this services is that, after subscribing, you setup and run a program on a machine behind your router (or on the router itself) that periodically checks the router’s current public IP address and updates your DNS entry on the dynamic DNS server. This way you will have a domain (usually a third level domain, like fanto.duckdns.org) which will always be associated with the current public IP address of your router. Then, if you own a “true” domain (like fantini.name), you just have to access your authoritative DNS and set up a CNAME record pointing to the third level domain on your dynamic DNS service.

Duck DNS

Googling around you can find many dynamic DNS services; most of them used to be free but they now require a subscription fee. Years ago, my first choice was DynDNS, but in 2014 they stopped offering their service for free and so I switched to Duck DNS. This DDNS service is working pretty good and to my knowledge is one of the few free dynamic DNS services out there.

When you register to Duck DNS (through your facebook account or another OAuth service provider), you will be assigned a token (a GUID that identifies your account) and you will be able to define up to 4 subdomains (like fanto.duckdns.org). Then in the install section of their site you will find how to setup the program that periodically updates your DDNS entry on your specific platform: they already support the most popular operating systems and a variety of routers (if your router is supported, you won’t need to run a dedidcated host to update your DDNS entry).

Since my router is not supported, I configured my slug to check and update my DDNS entry periodically. The configuration process was as simple as:

  • install curl (apt-get install curl)
  • create a shell script that sends my token and domain name to Duck DNS
  • add a cron entry that runs this shell script every 5 minutes

You can find the details of this procedure here (check the linux CRON section).

Configuring the Authoritative DNS

This last step can usually be easily achived by accessing an administration webpage from your domain maintainer; through this page you should be able to setup/configure your DNS entries. In your authoritative DNS you shold add a CNAME record pointing to the third level domain on your dynamic DNS service. Adding the following DNS entry on my own authoritative DNS did the trick for me:

www.fantini.name.  CNAME  fanto.duckdns.org.

Note that after you edit your authoritative DNS, it will take a few hours for your changes to propagate to other DNS servers around the world and become effective.

A Static Website

To manage my site I initially intended to use a CMS such as Joomla!, Wordpress or TWiki. However I soon realized that all of these solutions were too resource-demanding for my little slug and that my only option was to mantain a static site and have it served directly by my lighttpd instance. The advantage of this solution was that I would have avoided to run any additional software on the slug, thus saving resources. The disadvantage was that without a CMS I would have had to deal directly with the HTML pages; since I was planning to publish a blog and update it quite often, this idea was not thrilling to me. But after googling a bit, I found a possible solution to this problem: I came across a class of softwares known as static site generators which at the time (2009) where not so popular as they are today (2014). Generally speaking, a static site generator is a software that takes some text and templates as input and produces HTML files on the output.

After testing and comparing a few static website generators that were available at the time (like jekyll, nanoc, webby, Webgen) I finally decided to adopt jekyll, which looked perfect for my needs.

Jekyll

A simple, blog aware, static site generator written in Ruby. A “blog-aware” tool that quickly transforms your plain text (or Markdown) into static websites. Therefore this website comes to life as a bunch of text files I write on my laptop (using Notepad++) in a format called Markdown. These files are then processed by Jekyll together with other resources and transformed into a static HTML site. Jekyll demands the processing of the Markdown format to Maruku and makes use of Pygments for code syntax decoration. The look of the site comes from a free template I found on spyka, which I then adapted and modified to suit my needs.

TODO_FF: describe how to set up / configure jekyll NOTA_FF: 01/09/14 - installed Portable Jekyll 2.3.0 which replaces my old installation of Jekyll 0.11.0. See 01/09/14 blog post for details

DISQUS

Blog comments, which are the only dynamic part of the site, are managed by DISQUS.

TODO_FF: describe how to set up Disqus and embed the comments into a static site

Site Deployment

Finally, I use cwRsync to upload the generated HTML pages to the webroot of my slug.

TODO_FF: describe how to set up and configure cwRsync NOTA_FF: 01/09/14 - installed cwRsync 5.3.0 Free, which is portable - just copy cwrsync.cmd, fix CWRSYNCHOME and PATH and add the rsync command call at the bottom