In this project, we implemented a HTTP server in C++ 98, designed to serve static websites, handle GET, POST and DELETE methods, manage uploads from clients and provide CGI support for php and python scripts. Of course, the server is non-blocking and compatible with at least Google Chrome and Mozilla Firefox.
This website is hosted by this project.
git clone https://github.com/tgrasset/webserv.git
cd webserv
./webserv <path/to/config/file(optional)>
Examples of configuration files can be found in the ./configs
folder.
The program can be launched with several servers listening on different ports so you can have several server{}
blocks in the configuration file.
Here are some elements that can be defined for each server
:
host
: the IP address of the serverlisten
: the listening portroot
: the root directory of the serverindex
: the page served if the root directory is requested by the clientclient_max_body_size
: the maximum length in bytes of a request's bodyerror_page
: path of optional custom error pages for any http status codeserver_name
: this field is only used to differentate 2 servers listening on the same IP/port pair
Each server{}
block can include any number of location{}
blocks associated to a specific route where some particular behaviours can be defined with the following keywords:
allow_methods
: lists the methods authorized for this route (GET, POST and DELETE)index
: an index can be specified for any route and not just for the serverautoindex
: if no index page is provided, the server will generate an overview of the route's filesystem similar to thels
command in a shell contextupload_dir
: the directory where clients' uploaded file will be savedreturn
: followed by a status code and a route, this keyword is for redirections
This project was made with my teammates mbocquel and tgrasset at 42school.