- Project Overview
- Mandatory Features
- Project Compilation and Execution
- Tests - Usage Examples
- Contributors and License
The Webserv
project is designed to handle HTTP requests and responses, implementing basic functionalities of a web server
such as parsing HTTP requests, managing server configurations, handling connections, and serving static files or CGI scripts.
- HTTP/1.1 compliant
- Support for GET, POST, and DELETE methods
- Custom configuration file support
- Virtual hosting
- Autoindexing
- Error handling and custom error pages
- CGI script execution
To compile the project, clone the repository and use the provided Makefile.
git clone https://github.com/pin3dev/42_Webserv.git
cd 42_Webserv
make
If no configuration file is specified, the server will use the default configuration located at configs/default.conf.
./webserv [configuration file]
The configuration file allows you to set up the server and define its behavior. Below is an example of a basic configuration:
server {
server_name www.site1;
listen 8080;
host localhost;
root www/site1;
index index.html;
client_max_body_size 2M;
error_page 404.html;
location / {
allow_methods GET;
#try_file tutorial.html;
}
location /upload {
allow_methods GET DELETE;
}
location .py {
allow_methods GET POST;
cgi_path /cgi;
cgi_ext .py;
upload_to /upload;
}
location /favicon.ico {
allow_methods GET;
}
location /assets {
allow_methods GET;
autoindex on;
}
location /redirect {
allow_methods GET;
return /;
}
}
- listen: The port on which the server will listen.
- server_name: The server's domain name.
- root: The root directory for the server.
- index: The default index file.
- error_page: Custom error pages.
- location: Define specific behavior for certain URL patterns.
- autoindex: Enable directory listing.
- cgi_path: Path to the CGI executable.
- cgi_ext: File extension for CGI scripts.
- allow_methods: HTTP methods allowed for the location.
- upload_to: Directory for file uploads.
Makefile
: Instructions for compiling the project.
exe/
: Source files for the main server functionality.
inc/
: Header files.
configs/
: Example configuration files.
There is a tutorial page in HTML www/site1/tutorial.html
that helps with testing the server using curl
and directly in the browser.
This page provides examples and instructions on how to perform various HTTP requests and view the results.
To access the tutorial page:
- Ensure the server is running.
- Open a web browser and navigate to
http://localhost/tutorial.html
- This page will guide you through testing different endpoints and methods supported by the server.
- Ívany Pinheiro aka
@pin3dev
- Clara Franco aka
@clima-fr
Feel free to submit issues or pull requests if you have suggestions or improvements.
This project is open-source and available under the MIT License.