Webserv is a 42 project where you write your own HTTP server in C++. Find the subject here.
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.
Clone the repository:
git clone https://github.com/mariadaan/webserv.git
Compile the webserver through the makefile:
make
Run executable (optionally with a configuration file, which should be located in the root/conf
folder. No need to specify the path.):
./webserver default_server.conf
Or run with default configuration through the makefile:
make run
The server can be configured using a config file. The path-to-config file has to be added while running the server. Possible configurations:
- Choose ports and servernames of virtual servers
- Set up default error pages
- Limit client body size
- Set up routes with following possible configurations:
- Define accepted HTTP methods
- Set up HTTP redirections
- Define root directory
- Turn on/off directory listing
- Setup index files
- Execute CGI based on file extensions (currently only supports Python)
Specific config file rules:
- All text that is not in a server block is not taken into account
- All text gets truncated when a ';' or '#' is encounterd
- Start of server block has to be written as "server {"
- In the server body: only the following words are handled: 'listen', 'server_name', 'root', 'location', 'client_max_body_size', 'cgi', 'error_page'
- In the location body: the following words are handled: 'index', 'request_method', 'upload', 'autoindex', 'redirect', 'client_max_body_size', 'root'
- All other words are not taken into account
- For the 'client_max_body_size' k/K are read as kilo (*1000) and m/M as mega (*1000000)
Visit this Notion page to read more about the components of a web server.