The goal of this project is to build a HTTP 1.1 complaint webserver with non-blocking I/O operations.
This repository contains a non-blocking HTTP/1.1 server implemented in C++98. The server is designed to handle multiple connections simultaneously without blocking on I/O operations. Non-blocking I/O is a critical feature in modern network servers, enabling the server to handle many connections simultaneously without waiting for I/O operations to complete. The server supports basic HTTP/1.1 functionality, including handling GET, POST and DELETE requests. It also includes a simple configuration system that allows users to set up the server parameters, such as listening ports, document roots, and more, through a configuration file very similar to nginx.
In order to run the program first clone the repository:
git clone git@github.com:ferri17/webserver.gitOpen the folder:
cd webserver/Compile the program:
makeRun the program:
./webserv [path to configuration file]Note
If a path to a configuration file is not specified, the server will use a default configuration.
The configuration file syntax is very similar to the one used by nginx in it's http server directives. Multiple server directives can be added, multiple listen directives in each server, server names, root locations, autoindexing and more.
server
{
client_max_body_size 500;
listen localhost:8010;
server_name adria;
root ./html;
location / {
autoindex on;
error_page 404 /index.html;
allow_methods GET POST;
upload_store ./files_upload/;
index empty.html;
cgi .sh /bin/bash;
}
location /assets/ {
root ./cgi;
autoindex on;
}
location /test {
autoindex on;
root ./html/error_pages;
}
}
server
{
listen 127.0.0.1:8050;
server_name ferran;
root ./html;
location / {
autoindex on;
error_page 404 ./a/../error_pages/404.html;
allow_methods GET POST;
upload_store ./files_upload/;
index index.html;
cgi .sh /bin/bash;
}
}This project is written by @AdriaPriego and me as part of 42 School core curriculum.
