HTTPd15 Nov 2016 • Leave Comments
$ cd ~/workspace/webui-aria2 $ python3 -m http.server 6801 & or $ python2 -m SimpleHTTPServer 6801 &
Really primitive. Use it if you are lazy :).
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
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 127.0.0.1 -p tcp --dport 80 -j REDIRECT --to-ports 8080
Hence, there is no need to specify 8080 port in web URL.
Only root can and must chroot and drop privileges.
- Suffer from memory leak?
- Support CGI/FastCGI.
- Good at static web page.
- Popular than lighttpd?
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.
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.
- URL Forward is divided into two categories:
- By terminology, Forward and Redirect are used interchangeably, depending on the context. But usually, Forward is a broader concept, meaning Redirect or Frame.
- 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.
- 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.
- Platforms like Cloudclare, Freenom etc. support URL Forward nowadays.