Gatling

From Segfault
Jump to navigation Jump to search

Installation

libowfat

gatling is a small, high-performance webserver. To compile, we have to build libowfat first:

sudo apt-get install cvs gcc libc6-dev zlib1g-dev libssl-dev libcap-dev libmbedtls-dev     # Debian, Ubuntu

wget https://www.fefe.de/libowfat/libowfat-0.32.tar.xz{,.sig}

Verify the signature:

gpg --keyserver keys.openpgp.org --recv-keys 0xFC32CEECA534A9C6
gpg --tofu-policy good 0xFC32CEECA534A9C6
gpg --trust-model tofu --verify libowfat*.sig

Unpack:

tar -xJf libowfat*.tar.xz
cd libowfat*

Or, via CVS:

cvs -d :pserver:cvs@cvs.fefe.de:/cvs -z9 co libowfat
mv libowfat{,-cvs} && cd libowfat-cvs

Build:

make
sudo make install                                                                          # Edit GNUmakefile to set a different prefix!

Now libowfat should be installed:

$ ar t /opt/diet/lib/libowfat.a | wc -l
384

gatling

With that in place, we can install gatling:

wget https://www.fefe.de/gatling/gatling-0.16.tar.xz{,.sig}

Verify the signature:

gpg --trust-model tofu --verify gatling*.tar.xz.sig

Unpack:

tar -xJf gatling*.tar.xz
cd gatling*

Or, via CVS:

cvs -d :pserver:cvs@cvs.fefe.de:/cvs -z9 co gatling
mv gatling{,-cvs} && cd gatling-cvs

Build:

make
sudo make install                                                                          # Edit GNUmakefile to set a different prefix!

Now gatling should be installed:

$ ldd /opt/diet/bin/gatling 
       linux-gate.so.1 =>  (0xb774a000)
       libz.so.1 => /lib/i386-linux-gnu/libz.so.1 (0xb772b000)
       libcrypt.so.1 => /lib/i386-linux-gnu/tls/i686/nosegneg/libcrypt.so.1 (0xb76fa000)
       libcrypto.so.1.0.0 => /lib/i386-linux-gnu/libcrypto.so.1.0.0 (0xb754f000)
       libc.so.6 => /lib/i386-linux-gnu/tls/i686/nosegneg/libc.so.6 (0xb73a4000)
       libdl.so.2 => /lib/i386-linux-gnu/tls/i686/nosegneg/libdl.so.2 (0xb739f000)
       /lib/ld-linux.so.2 (0xb774b000)

$ ldd /opt/diet/bin/tlsgatling 
       linux-gate.so.1 =>  (0xb775a000)
       libssl.so.1.0.0 => /lib/i386-linux-gnu/libssl.so.1.0.0 (0xb76fb000)
       libcrypto.so.1.0.0 => /lib/i386-linux-gnu/libcrypto.so.1.0.0 (0xb7550000)
       libz.so.1 => /lib/i386-linux-gnu/libz.so.1 (0xb753a000)
       libcrypt.so.1 => /lib/i386-linux-gnu/tls/i686/nosegneg/libcrypt.so.1 (0xb7508000)
       libc.so.6 => /lib/i386-linux-gnu/tls/i686/nosegneg/libc.so.6 (0xb735e000)
       libdl.so.2 => /lib/i386-linux-gnu/tls/i686/nosegneg/libdl.so.2 (0xb7359000)
       /lib/ld-linux.so.2 (0xb775b000)

Usage

A basic startup would look something like this:

gatling -V -d -u www-data -F -U -S -p 80 -I index.html -c /var/www

Options explained:

-V disable virtual hosting mode
-d generate directory index
-u switch to this UID after binding
-F do not provide FTP
-U disallow FTP uploads
-S do not provide SMB service
-p bind-to-port
-I also try name, used for "index.php" etc
-c chroot to dir after binding

Note: since we're starting gatling with -c ("chroot to dir after binding"), we have to make sure /dev/urandom exists in the chroot:

DOCROOT=/var/www
mkdir $DOCROOT/dev
mknod -m 0644 $DOCROOT/dev/urandom c 1 9

There's also TLS support with tlsgatling

openssl dhparam -out dhparams.pem 2048
cat server.key server.crt dhparams.pem > server.pem
chmod 0440 server.pem && chgrp www-data server.pem && mv server.pem /var/www/

tlsgatling -V -d -u www-data -F -U -S -e -p 80 -p 443 -I index.html -c /var/www

See gatling -h for all options.

Links