webserv is a 42/Codam project about writing our own HTTP server in C++
This is a collaborative project between nhariman, salbregh, and mjiam.
This is a simple HTTP/1.1 web server that can handle GET, POST, and DELETE requests.
Our webserver uses the same non-blocking, event-driven architecture that nginx does. This allows the server to handle a high amount of requests with speed.
We use kqueue
to handle the multiplexing, which means the server can only run on Mac machines.
Detailed project specifications can be found here.
The server settings are configured through a .conf
configuration file based on Nginx. The list of accepted directives can be found here.
From the root of the repo, run make && ./webserv
to build and start the web server.
The webserv
executable takes an optional configuration file argument:
$ ./webserv [your_config_file.conf]
Otherwise the web server defaults to using the settings in config_files/default.conf
.
The web server can be interfaced with through any browser or tools like curl and telnet.
If using the default configuration, navigating to localhost
on port 80 (default), 4242, and 8080 showcases 3 different websites with different configuration settings.
- Standard functionality
- Internal and external redirects
- Custom error pages
- Autoindexing
We made a wiki containing information about:
- project requirements
- server specs
- implementation and research notes
- code documentation
- Persistent connections
- Accepting POST file uploads other than text files
- Testing was done using GoogleTest. Our tests can be found in the
google_test
folder. - A script for quickly setting up and running GoogleTest was prepared by Michelle. It requires CMake to be installed.
- Intro to network programming
- Simple, clear introduction to writing a basic HTTP server
- Easy-to-read explanation of HTTP workings by Mozilla
- Socket Programming in C/C++
- Network-related system calls
- Video series: network programming
- Video: Socket Programming Tutorial In C For Beginners
- IO Multiplexing: select vs poll vs kqueue
- Using kqueue to implement a streaming server
- Kqueue tutorial
- Non-blocking event-driven architecture behind nginx
- How nginx processes requests
- Server and location block selection algorithms
- How nginx config files work
- How the return directive works
- Redirections
- Auto-index
- Full config example
- fastCGI config example
- HTTP Request Parsing using a Finite State Machine
- HTTP header line breaks
- Chunked transfer-encoding
- Boundary strings in POST file uploads (not handled by our server)
- Common Gateway Interface (CGI) – How it Works, Features & Applications
- How the web works: HTTP and CGI explained
- 7230: Message Syntax and Routing
- 7231: Semantics and Content (requests, headers, response codes)
- 3986: URI Generic Syntax
Michelle Jiam - LinkedIn / Github
Sanne Albreghs - LinkedIn / Github
Niks Hariman - LinkedIn / Github