Merecat httpd is a simple, small and fast HTTP server, originally based on thttpd
C C++ HTML M4 Makefile Shell Other
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
debian debian/changelog: Mention new HTTP gzip compression Jan 22, 2017
man Add -P PIDFN option to be able to change daemon PID file Feb 18, 2017
scripts scripts/: Update, thttpd --> merecat Jan 22, 2017
src Fix off-by-one in string realloc Feb 22, 2017
tests tests: Default to use local merecat.conf Feb 19, 2017
www De(void) code Feb 19, 2017
.gitignore
.travis.yml Travis-CI: Enable test suite Feb 12, 2017
LICENSE LICENSE: Remove necessary lead-in added by me Jan 21, 2017
Makefile.am Add example throttle.conf Feb 18, 2017
README.md README: Update with new configure options Feb 21, 2017
README.thttpd Initial commit: the README's Mar 28, 2012
TODO TODO: Cleanup, things have actually been fixed :) Nov 5, 2016
autogen.sh Use autoreconf tool to regen build system files Jul 4, 2016
configure.ac
merecat.conf Set a default Cache-Control: max-age=604800 (a week) Feb 19, 2017
merecat.service.in
throttle.conf Add example throttle.conf Feb 18, 2017

README.md

Merecat httpd ∴ Small Simple Speedy Server

Travis Status

Merecat started out as a pun at Mongoose, but is now useful for actual web serving purposes. It is however not a real Meerkat, merely yet another copycat, forked from the great thttpd created by Jef Poskanzer.

The limited feature set makes it very quick. Virtual hosts and the URL-traffic-based throttling are just about its only features. This small footprint makes Merecat very suitable for small and embedded systems, even those smaller than a Raspberry Pi.

For questions see the included merecat(8) man page or the FAQ.

Merecat is free software under the simplified 2-clause BSD license.

Authentication

To protect a directory in your ~USERNAME/public_html/, create a simple .htpasswd file using the included htpasswd tool:

cd ~/public_html/Downloads
htpasswd -c .htpasswd friend
Changing password for user friend
New password: *****
Re-type new password: *****

Virtual Hosts

Setting up virtual hosts on a server can be a bit of a hassle with other web servers. With Merecat you simply create directories for each host in the web server root:

 /var/www/
   |-- icons/
   |-- cgi-bin/
   |-- errors/
   |    `-- err404.html
   |-- ftp.example.com/
   `-- www.example.com/

Edit /etc/merecat.conf:

virtual-host = true
cgi-pattern = /cgi-bin/*|**.cgi

Now the web server root, /var/www/, no longer serves files, only virtual host directories do, execpt for the shared files in icons/, cgi-bin/, and errors/.

On Linux bind mounts can be used to set up FTP and web access to the same files. Example /etc/fstab:

/srv/ftp  /var/www/ftp.example.com  none  defaults,bind  0  0

Optimizing Performance

There are many tricks to optimizing the performance of your web server. One of the most important ones is browser caching. Merecat supports both ETag: and Cache-Control:, however to enable the latter you need to define the max-age setting in /etc/merecat.conf:

max-age = 3600        # One hour

The value is completely site dependent. For an embedded system you might want to set it to the maximum value, whereas for other scenarios you will likely want something else. By default this is disabled (0).

Another trick is to employ gzip compression. Merecat has built-in support for serving HTML, CSS, and other text/* files if there is a .gz version of the same file. Here is an example of how to compress relevant files:

$ cd /var/www/
$ for file in `find . -name '*.html' -o -name '*.css'`; do \
      gzip -c $file > $file.gz; done

Build Requirements

Merecat depends on libConfuse which, if built from source, by default installs to /usr/local. Non Debian/Ubuntu systems rarely support this GNU standard, so this is how you reference it for the Merecat configure script:

PKG_CONFIG_LIBDIR=/usr/local/lib/pkgconfig ./configure

To build Merecat without support for /etc/merecat.conf:

./configure --without-config

If you build from GIT sources and not a released tarball, then remember:

./autogen.sh

To install httpd into /usr/sbin/, default index and icons into /var/www, and config file to /etc/merecat.conf:

./configure --prefix=/usr --localstatedir=/var --sysconfdir=/etc
make
sudo make install

Features

Merecat consists of a front-end, merecat.c, and a standalone HTTP library, libhttpd.c, which can be tweaked in various ways and used for embedding a web server in another applications if needed.

The most common options are available from the merecat command line and the merecat.conf configuration file. Other, less common options, can be enabled using the configure script:

--enable-htaccess      Enable .htaccess files for access control
--enable-htpasswd      Enable .htpasswd files for authentication
--enable-public-html   Enable $HOME/public_html as ~USERNAME/
--enable-msie-padding  Enforce padding of httdp error messages
                       sent to Internet Explorer, otherwise it will
                       detect too short msg and display its own.

The source file merecat.h has even more features that can be tweaked, some of those are mentioned in the man page, but the header file has very useful comments as well.

Origin & References

Merecat is a fork of sthttpd, which in turn is a fork of the original thttpd -- the tiny/turbo/throttling HTTP server.