42 project, recoding our own web server in C++. A program capable of running an HTTP server, handling requests, and parsing configuration files. webserv is a HTTP/1.1 server written in C++98. It must be conditionnal compliant with RFC 7230 to 7235.
# Compile the sources
make
# Run the server
./webserv [config_file]
sets configuration depending on the given uri.
bind the given address to the port. if no address is given, binds 0.0.0.0.
sets names of a virtual server.
sets the directory for requests.
sets the allowed methods for the root.
defines the URI that will be shown for the specified errors.
defines the requests location.
enables or disables the directory listing output.
defines files that will be used as an index.
defines a CGI binary that will be executed for the given extension.
It sets the maximum allowed size of the client request body, specified in the “Content-Length” request header field.
server
[
host:0.0.0.0
port:80
port:22
server_name:localhost
allowed_methods:GET
location:/
{
root=website
default=index.html
autoindex=on
}
error_page:401:website/error_page/401.html
error_page:403:website/error_page/403.html
location:/*.bla
{
allowed_methods=POST
cgi_uri=/users/layeredchoas/test/
}
location:/dir
{
root=/users/layeredchoas
default=TestFile
autoindex=on
}
location:/autoindex
{
root=/users/layeredchoas/files
default=nothing
autoindex=on
}
location:/upload
{
root=/users/layeredchoas/upload_folder
allowed_methods=GET,PUT,HEAD,POST
limit_client_body=20
}
location:/methods
{
allowed_methods=HEAD
}
location:/private/
{
root=/goinfre/ayennoui/ybouddou/private
default=payments
access=/goinfre/ayennoui/ybouddou/private/.access.prv
}
]
HTTP/1.1 : Message Syntax and Routing (RFC 7230)
HTTP/1.1 : Semantics and Content (RFC 7231)
HTTP/1.1 : Conditional Requests (RFC 7232)
HTTP/1.1 : Range Requests (RFC 7233)
HTTP/1.1 : Authentication (RFC 7235)