Skip to content

Welhox/Webserv

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Webserv - A Lightweight HTTP/1.1 Server in C++

Linux
A non-blocking HTTP/1.1 server written in C++, inspired by NGINX.

🚀 Introduction

Webserv is a lightweight, event-driven HTTP server built using C++ and epoll(). It is designed to handle multiple requests efficiently while remaining non-blocking. It supports GET, POST, and DELETE methods and can execute Python scripts via CGI.

👥 Contributors

  • @Welhox – Developed and implemented full HTTP response handling, including the core functionalities of GET, POST, and DELETE methods on the server side.
  • @tcampbel22 – Configuration file parsing, Logger
  • @codinggolfer – Request parsing

🛠 Collaborative Work

  • CGI support & main server loop developed together

✨ Features

Non-blocking I/O (using epoll())
CGI support for executing Python scripts
Custom error pages at different levels: location block, server level, and default error handler
Directory listing with resource links
Multiple server instances
Basic file upload support
Configuration-based setup (similar to NGINX)

🛠 Installation

Requirements:

  • A Linux environment (due to epoll() usage)
  • make and g++ are required to compile the project. If they are not installed, you can install them using:
    sudo apt update && sudo apt install build-essential

🔧 Build Instructions

git clone https://github.com/Welhox/webserv.git
cd webserv
make

▶️ Usage

To start the server, provide a configuration file:

./webserv config/server.conf

Default Address: 127.0.0.1:8081

⚙️ Configuration

Webserv reads configurations from a file (similar to NGINX). Example configuration files can be found in the config/ directory.

Example server.conf:

server {
    host 127.0.0.1
    port 8081;
    server_name myserver;

    error_page 404 /errors/404.html;
    
    location / {
        root /root/var/html;
        index index.html;
        methods GET;
    }
    
    location /cgi-bin/ {
    	cgi_path /root/bin/cgi/;
    	cgi_script cgitester.py;
    }

}

📸 Examples

Custom 404 Error Page

404

Directory Listing

directory-listing

File Upload Support

File-upload

Homepage

Homepage

About

Build a server in c++

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • C++ 85.0%
  • HTML 12.3%
  • Python 1.6%
  • Makefile 1.1%