Thttpd: Difference between revisions

From Leo's Notes
This page was last edited on 1 January 2022, at 20:46.
mNo edit summary
m make STATICFLAG for cgi-src due to weird make file
 
(One intermediate revision by the same user not shown)
Line 15: Line 15:
# make CCOPT='-O2 -s -static' thttpd
# make CCOPT='-O2 -s -static' thttpd
# cd cgi-src
# cd cgi-src
# make CCOPT='-O2 -s -static' all
# make STATICFLAG='-O2 -s -static' all
| lang = terminal
| lang = terminal
}}
}}
Line 52: Line 52:
* http://www.acme.com/software/thttpd/thttpd_man.html
* http://www.acme.com/software/thttpd/thttpd_man.html
*Merecat httpd - https://github.com/troglobit/merecat/
*Merecat httpd - https://github.com/troglobit/merecat/
{{Navbox Linux}}
[[Category:Linux]]
[[Category:LinuxUtilities]]

Latest revision as of 20:46, 1 January 2022

thttpd is a simple, portable, and minimalistic HTTP server. More information from their home page at: http://www.acme.com/software/thttpd/

Compiling

thttpd can be compiled with plain build utilities. On Alpine Linux, run the following:

# apk add gcc musl-dev make

## Get thttpd and compile
# wget http://www.acme.com/software/thttpd/thttpd-2.29.tar.gz
# tar -xzvf thttpd-2.29.tar.gz
# cd thttpd-2.29

## Compile
# ./configure
# make CCOPT='-O2 -s -static' thttpd
# cd cgi-src
# make STATICFLAG='-O2 -s -static' all

Because the binary is compiled and linked statically, you can run thttpd within an empty container.

Usage

Description Command
Start thttpd on port 8080 serving /www thttpd -h 0.0.0.0 -p 8080 -d /www
Allow CGI anywhere thttpd -h 0.0.0.0 -p 8080 -d /www -c **
Log to stdout thttpd -h 0.0.0.0 -p 8080 -d /www -l -
Start thttpd using a configuration file thttpd -C thttpd.conf

Redirection

Redirections are handled by a separate CGI program. Included in the source tree is cgi-src/redirect.c which reads a .redirects file for the appropriate destinations.

To get this working:

  1. Compile cgi-src/redirect.c.
  2. Move redirect to your web root. Call it redirect.cgi.
  3. Symlink your source (for example, index.html if you want to redirect the root location) to redirect.cgi
  4. Add / http://somewhere.example.com/ into .redirects.

See also