HTTP server in C++ developed by @ixu42, @nikkxll, @madfcat.
Terminal logs preview
Server main page
Name-based virtual hosting allows several serverName
s to be served from the same ipAddress
:port
Each config part is defined with a header: [main]
, [server]
or [location]
.
[main]
must be the first config part defined. Only one [main]
is allowed.
Each [location]
belongs to the first [server]
defined before it. [location]
is invalid without [server]
.
Each server can have multiple location.
Empty lines are allowed.
Main config is used to define CGI interpreters paths.
[main]
py /usr/bin/python3
php /usr/bin/php
Allowed fields: ipAddress
, port
, serverName
, error
, clientMaxBodySize
If no ipAddress
is provided, webserv will try to create server on all the interfaces available.
[server]
ipAddress 127.0.0.1
port 8006
serverName host2.website1.com
error 404 "webroot/user-pages copy/404.html"
clientMaxBodySize
can be set in G
, M
, K
, B
clientMaxBodySize 100KB
Webserv has default error pages stored in pages/
directory. For example, pages/404.html
. The user definded error pages will take priority.
Custom error pages can define custom error pages like this:
error 404 "user-pages copy/404.html"
error 405 user-pages/405.html
error 500,501,505 other-user-pages/500.html
The priority order: redirect -> user defined index -> index.html (default) -> directory listing
In this case $request_uri
will be substituted to everything that will be after /redirect/
[location]
path /redirect/
redirect https://google.com/$request_uri
[location]
path /assets-redirect
redirect /assets/
All the url subdirectories will also have directory listing if the parent url directory location has autoindex on
[location]
path /
root website1/
autoindex on
Successful upload will redirect to the requested path automatically.
[location]
path /uploads/
root webroot/website2/uploads/
autoindex on
upload on
Can be .html
or .htm
file.
[location]
path /uploads/
root webroot/website2/uploads/
index index.html
methods
can be set to comma-separated list of method get
, post
, delete
.
[location]
path /uploads/
root webroot/website2/uploads/
methods get,post,delete
index index.html
Each comment should be on a separate line
# Simple comment
[main]
py /usr/bin/python3
php /usr/bin/php
# host1.website1.com @ 127.0.0.1:8006
[server]
ipAddress 127.0.0.1
port 8006
serverName host1.website1.com
error 404 user-pages/404.html
# error 405
[location]
path /
root website1/
autoindex on
[location]
path /pic-redirect
redirect /skull/
[location]
path /redirect/
redirect https://google.com/$request_uri
# host2.website1.com @ 127.0.0.1:8006
[server]
ipAddress 127.0.0.1
port 8006
serverName host2.website1.com
error 404 "webroot/user-pages copy/404.html"
[location]
path /
root "website1 copy/"
autoindex on
[location]
path /pic-redirect
redirect /assets/
[location]
path /redirect/
redirect https://google.com/$request_uri
# host1.website2.com @ 127.0.0.1:8007
[server]
ipAddress 127.0.0.1
port 8007
serverName host1.website2.com
[location]
path /
root webroot/website2/
autoindex on
[location]
path /uploads/
root webroot/website2/uploads/
autoindex on
upload on
✅ Passed with 125/100 ✅
To run the program with default setting of the config
make && ./webserv
To run certain config file
make && ./webserv default/config_name.conf
To compile and run the program in DEBUG mode
make debug && ./webserv
ixu: ixu@student.hive.fi | dnikifor: dnikifor@student.hive.fi | vshchuki: vshchuki@student.hive.fi