Skip to content

ferri17/webserver

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

92 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

GitHub Repo stars GitHub top language GitHub code size in bytes GitHub last commit (by committer) MacOS compatibility

HTTP 1.1 non-blocking webserver

The goal of this project is to build a HTTP 1.1 complaint webserver with non-blocking I/O operations.

About The Project

Webserver demo intro

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.

Getting Started

In order to run the program first clone the repository:

git clone git@github.com:ferri17/webserver.git

Open the folder:

cd webserver/

Compile the program:

make

Run 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.

Configuration file

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;
	}
}

Authors

This project is written by @AdriaPriego and me as part of 42 School core curriculum.

About

Non-blocking HTTP webserver written in C++98.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages

  • C++ 91.6%
  • Makefile 3.0%
  • HTML 2.7%
  • PHP 1.0%
  • CSS 0.6%
  • JavaScript 0.5%
  • Other 0.6%