A C++98 HTTP web server project, for the 42 school curriculum.
Goal:
Build a fully functional HTTP server from scratch using C++98.
- Executable:
./webserv [configuration file]
- Main Protocol: HTTP (HyperText Transfer Protocol)
- Testable with: Real web browsers, telnet, and compared against NGINX
Mandatory:
- Non-blocking I/O using
poll()
- Serve static files (HTML, images, etc.)
- Handle HTTP methods:
GET
,POST
,DELETE
- File upload support
- CGI execution support (e.g., PHP, Python scripts)
- Multiple server blocks with virtual hosting
- Multiple listening ports
Configuration file (inspired by NGINX) can specify:
- Server names
- Root directories
- Allowed methods
- Directory listing
- Max body size
- Default files
- HTTP redirection
- Use only allowed syscalls (
recv
,send
,accept
,poll
, etc.) - No external or Boost libraries
- Handle client disconnections and errors gracefully (never crash)
- Remain non-blocking at all times
- Do not
execve
another server - Only one
poll()
(or equivalent) loop for all I/O
- Cookie and session handling
- Multiple CGI support
A Dockerfile
is included to simplify building and running the server in a containerized environment.
To build and run with Docker:
make up
(Adjust the port as needed, and map configuration files/volumes if required.)
- Includes a
Makefile
with rules:all
,clean
,fclean
,re
,$(NAME)
- This project is maintained in a Git repository
To build:
make
To run:
./webserv [configuration file]
- Peer evaluation will test all mandatory features and resilience
- Server must be testable with web browsers, telnet, and compared to NGINX behavior
Project for educational purposes as part of the 42 school curriculum.