theozanchi / 42_Berlin_webserv

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Webserver logo

Grade badge Language Badge Library Badge

Webserver

This project is about coding our own webserver in C++, mimicking the behaviour of NGINX. It is a group project done with Lola Le and Selina Pradel

The full subject can be found here.

Downloading and compiling the project

Clone the repository and use make to compile

git clone https://github.com/theozanchi/42_Berlin_webserv/tree/main
cd 42_Berlin_webserv
make

Compilation screenshot

Running the program

The program can be launched with or without an argument. The argument is a configuration file that has to follow the format of nginx.conf files:

server {
	listen		8080;
	host		localhost;
	server_name	www.default.com default.com;
	root		./content/default_website;

	# Default error pages configuration
	error_page	404 "./content/error/404.html";
	error_page	405 "./content/error/405.html";
	error_page	500 502 503 504 "./content/error/50x.html";

	# Limit client body size
	client_max_body_size		10M;
	client_body_in_file_only	on;
	client_body_buffer_size		128K;
	client_body_timeout			30s;

	location / {
		# Define accepted HTTP methods
		allow	GET;

		# Set a default file to answer if the request is a directory
		index	"index.html" "index.htm";

		# Directory listing settings
		autoindex	off;
	}
}

The target make go can be used to directly build the executable and launch it with a config file named webserv.conf:

Make go

Supported features

  • Multiplexing using poll()
  • HTTP 1.1 with methods GET, POST and DELETE
  • Possibility to upload files
  • CGI interface supporting C++
  • Redirections

About


Languages

Language:C++ 66.9%Language:HTML 25.2%Language:CSS 5.0%Language:Makefile 1.9%Language:PHP 0.9%Language:Perl 0.0%