FeatherServer is an open-source webserver that focuses on security and performance. Therefore, a very minimal configuration is used to reduce overhead.
Currently the following features are present:
- An HTTP redirection server. This server requires secure connections. Non-secure connections will be upgraded by the RedirService.
- An HTTPS server, this is main component of the project.
- The industry standard HTTP/1.1 protocol is used to communicate with clients (webbrowsers et al.)
- Client-side Caching is enabled by handling conditional requests. This is achieved by sending a
Last-Modified
header and validating the future request headerIf-Modified-Since
. - File system overhead is reduced by caching files in memory.
In the future, the following features can be expected:
- Automated Certificate Management Environment (AMCE)
- HTTP/2
- Online Certificate Status Protocol (OCSP)
- A configure script (maybe Autotools, Meson, etc.)
- Proper system integration with
init
/systemd
and the/var/log/
system.
This code is designed to primarily use POSIX and C89 functions, but some minimal C99-standard functions and some libraries are used. This basically means that most UNIX-like systems are supported. Currently, the following platforms are supported:
- Linux
- FreeBSD
- OpenBSD
Please refer to the build instructions for more details. Windows systems are not supported and will probably never be supported.
This project tries to keep the amount of dependencies used minimal, but some are simply mandatory.
This project locates its' dependencies by using pkg-config
. On most systems, this is already installed. On some BSDs, it can be installed by running the following command:
$ pkg install pkgconf
FeatherServer's main component is the HTTPS server, which is a server that uses connections encrypted by the TLS protocol. FeatherServer achieves this secure connection by using the OpenSSL or one of its compatible forks, such as LibreSSL. To quickly install OpenSSL, execute the following commands:
$ git clone https://github.com/openssl/openssl
$ cd openssl
$ ./config
$ make
$ sudo make install
If you prefer to use your package manager, please make sure you also have the developer package installed. On apt
platforms (Debian/Ubuntu et al.), this is libssl-dev
:
sudo apt install libssl-dev
To achieve fast transfers between the server and its' clients, FeatherServer uses Brotli, an open-source compression library written in C and created by Google. To quick-install Brotli, execute the following commands:
$ git clone https://github.com/google/brotli
$ mkdir brotli/build && cd brotli/build
$ ../configure-cmake
$ make
$ sudo make install
To use your package manager, execute the following command:
sudo apt install libbrotli1 libbrotli-dev
To get a clone of the repository, run the following command:
$ git clone https://github.com/wooshdev/feather
This will create a new folder in your current working directory, which is named feather
.
Make sure your system is supported. To check if your platform is supported, confirmt that it is listed in the Platform Support section.
A modern compiler is recommended, like Clang or GCC. There is currently no configure script, so the default compiler used is Clang. To change this, modify the CC
variable in the Makefile. Changing the compiler can also be done by passing it to the make
command, e.g. make CC=gcc
.
Because of the lack of a configure script, this project contains a out-of-the-box working Makefile. Simply put: to build the project, execute the following:
$ make
If you wish to use a different compiler than the preconfigured clang
compiler, such as the GCC compiler which is installed on most UNIX systems, do the following:
$ make CC=gcc
If you wish to enable the experimental HTTP/2 implementation, add the ADDITIONAL_CFLAGS=-DOPTIONS_ENABLE_HTTP2
flag, e.g.:
$ make ADDITIONAL_CFLAGS=-DOPTIONS_ENABLE_HTTP2
This will set the OPTIONS_ENABLE_HTTP2
macro and informs the compilation that HTTP/2 should be used. To combine options, simply concatenate:
$ make ADDITIONAL_CFLAGS=-DOPTIONS_ENABLE_HTTP2 CC=gcc
The above will use the GCC
compiler and enable HTTP/2.
The executable will compiled to ./server
in the current working directory, and isn't put in /usr/bin
, /usr/local/bin
or some other system directory. Also, no init
/systemd
intergration is available, thus running the server simply invoke the ./server
binary, either in tmux/screen or using jobs. Future integration with more systems may be expected.
The project has been tested quite a bit. This section contains tools to test the code with. The Makefile contains targets useful for debugging, even though its primary use is building.
Valgrind is used for memory debugging, memory leak detection and system-resource leak detection. A useful make target is memory
, which will run the executable in a controlled mode.
$ make memory
Note that this target does not (re)build the program.
Cppcheck is a static analysis tool. It can be used for finding bugs that weren't found or caught by human revision. To run the tool, make sure you have it installed (see the project page for more information).
$ make cppcheck
include-what-you-use (IWYU) is a tool to find unnecessary #include <...>
's in code. Make sure you have installed the tool before use. To run the tool, execute the following command:
$ make clean all -k CC=include-what-you-use
Explanation: The two clean
and all
targets will insure the complete codebase will be scanned. The -k
option is there to insure the Makefile 'compilation' continues after warnings/errors occur. IWYU is a Clang plugin and acts like the compiler, therefore the CC
variable is overwritten.
clang-tidy is a linter tool that can – just like cppcheck
– analyze code for possible bugs. The tool is a clang plugin, and runs as the compiler. clang-tidy
doesn't recognise all the Clang/GCC CFLAGS/LDFLAGS as with normal compilation, so the CC
variable can't be replaced. To run the tool, do the following:
$ clang-tidy <compilation unit> -- -I .
Where <compilation unit>
is a .c file, for example main.c
.
Infer is an analysis tool created by Facebook. It finds errors previously not found by other static analysis tools. Click here for install instructions. To run Infer on this project, execute the following command:
$ infer run -- make clean all
This program will ensure Infer uses a clean build of the repository.
Standalone components should be tested using Unit Tests
. These are tests that will use a certain component of the program and feed it various types of input and checks the result. The tests are located in the tests
folder.
The program can be roughly benchmarked using the following script:
$ time tests/redir.sh
This script will query the Redirection Service
running on port 80 . It will perform 100 requests, and using the time
command the time of execution will be kept track off. Note that this script uses wget
, which is a tool that performs HTTP requests. It will probably be already installed on most Linux systems, but you can use apt
if it doesn't. To install it on a BSD platform, execute the following command:
On NetBSD:
$ pkg install wget
On FreeBSD:
pkg_add wget
The following make targets are present in the Makefile:
Target | Description |
---|---|
all | This is the default target, and will create the executable binary. |
clean | This will delete all binaries created, and will restore the clone to the original state. |
cppcheck | The cppcheck target analyzes the source code. For more information, see the [Cppcheck](#testing-cppcheck] test section. |
memory | The memory target runs binary in an enclosed mode using Valgrind. For more information, see the Valgrind test section. |
This project is licensed under "BSD 2-Clause Simplified" license. This project uses the Brotli library for compression, which is licensed under the MIT license. OpenSSL is mainly licensed under the Apache License v2.