A multi-worker HTTP server written in C.
Nothing too special, just another personal project of mine!
cerve
at glance
- portable web-server for unix OSs
- easy to use minimal CLI
- multi-worker support
- support 62 unique mime-types (some may say it as a gimmick)
- zero third-party dependencies
- highly configurable and extensible (am I repeating my self)
- yet another hackable http-file-server written by a C-lang noob for noobies
- cerve is compatible with cosmopolitan! hence can build cross platform binaries out of the box.
- head over to the release page and download the latest compiled binary.
- make it executable (
chmod +x cerve_v*
) - run by executing the binary (
./cerve_v*
)
- clone the repo
- make use of the
Makefile
:) - (optional) test if everything work fine
- (optional) to get a production build execute :
make build
Feel free to tinker with other c compilers. (by default gcc is supported).
For instance, cerve is compatible with cosmopolitan and one can compile it with cosmocc, using
make build CC=./cosmocc/bin/cosmocc ARCH=all
# feel free to change the cosmocc bin path (to read more about cosmocc, have a peek at https://github.com/jart/cosmopolitan)
that's it enjoy the app
execute ./cerve --help
for getting the detailed usage info
- -h | --help : print help and exit
- --version : print version and exit
- -v | --verbose : an integer between 1 and 4, inclusive of those values representing different log levels. higher values for detailed logs. 1 for minium logging default to 4
- -w | --workers : number of workers to be used defaults to 4
- -p | --port : system port at which the server to listen for connections. defaults to 8000
- --disable-socket-reuse : (flag) if provided the SO_REUSEADDR will not be set.
- --res-headers : add custom response headers. Defaults to none. expects a newline separated utf-8 text files with colon separated key values. syntax reference: https://httpwg.org/specs/rfc9112.html#rfc.section.2.1
- --serve-dir : specify custom serve directory. defaults to the current working directory
cerve accepts custom response headers, which can be specified using the --res-headers
option. To configure custom headers, create a simple HTTP header file (UTF-8 encoded) without any unnecessary intermediate whitespace, as demonstrated in the example file: misc/example.http-custom-headerfile.txt
.
Found a bug?? That you would! Feel free to raise an github issue (or maybe a pull request (only if you got that much time))