ZNHOO Whatever you are, be a good one!


Lightweight HTTPd

  1. Python

    $ cd ~/workspace/webui-aria2
    $ python3 -m http.server 6801 &
    $ python2 -m SimpleHTTPServer 6801 &

    Really primitive. Use it if you are lazy :).

  2. darkhttpd;

    It's pretty handy for temporary serving a static web page with multiple extended feature than Python's.

    ~ # darkhttpd /var/public_html --chroot --daemon --no-listing --uid nobody --gid nobody --maxconn 1 --log /var/public_html/traces.log
    ~ $ darkhttpd ~/opt/public_html --daemon --no-listing --maxconn 1 --log ~/opt/public_html/traces.log
    1. Default port under root is 80 while 8080 for normal accounts. We can take vantage of iptable's REDIRECT module of nat table.

      If darkhttpd is running on remote host (i.e. real deployment), use PREROUTING chain:

      # iptables -t nat -A PREROUTING -p tcp --dport 80 -j REDIRECT --to-port 8080

      Loopback devices (like localhost) do not use the PREROUTING chain. If darkhttpd is running on localhost (i.e. for test), use OUTPUT chain:

      # iptables -t nat -I OUTPUT -d -p tcp --dport 80 -j REDIRECT --to-ports 8080

      Hence, there is no need to specify 8080 port in web URL.

    2. Only root can and must chroot and drop privileges.

  3. lighttpd;
    1. Suffer from memory leak?
    2. Support CGI/FastCGI.
  4. nginx;
    1. Good at static web page.
    2. Popular than lighttpd?

CNAME vs URL Forward

  1. A CNAME record is carried out on DNS server, irrelevant to server (SSH, HTTP, FTP etc.). That is to say, the CNAME url is not hosted on your servers at all.

    The CNAME translation process is transparent to browse client, without user end involvement.

  2. URL Forward is usually done on web server.

    The server examines the host field of HTTP header, and return back the target URL to browser client if that matches a Redirect/Forward rule.

  3. URL Forward is divided into two categories:
    1. By terminology, Forward and Redirect are used interchangeably, depending on the context. But usually, Forward is a broader concept, meaning Redirect or Frame.
    2. URL Redirect (i.e. 301, 302 Unmasked) is what we usually refer to. The browser gets a HTTP 3XX status code and moves permanently to the new site. Broswer address bar is updated to the target URL.
    3. URL Frame (Cloaking/Masking) is similar but keep the original fetched web page. The new HTTP response will be embedded as a frame so that the visitor will always see the original URL in the address bar.
  4. Platforms like Cloudclare, Freenom etc. support URL Forward nowadays.


  1. Big list of http static server one-liners
  2. alpinelinux wiki