heleenoomen / webserv

This project is about writing your ow HTTP server. You will be able to test it with an actual browser. HTTP is one of the most used protocols on the internet. Knowing its arcane will be useful, even if you won’t be working on a website.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

webserv

webserv is a C++ HTTP server that provides basic functionalities for serving web pages, handling HTTP requests and responses, and managing sockets.

Installation

  1. Clone the repository: git clone https://github.com/FVNRLS/webserv
  2. Build the project: make

Running the server

To run the server, execute the following command in the terminal:
./webserv config_file

Alternatively execute the following command to run the server from default configuration file:
make run

Dependencies

  • C++98
  • Make
  • CMake (optional, for building the project)
  • python3
  • php

Setup

  1. Verify if some packages has been already installed by running the following commands in the terminal:
  • gcc --version
  • make --version
  • cmake --version
  • python3 --version
  • php --version
  1. install missing packages.

Setup on Mac (with brew)

  • brew update
  • brew install gcc
  • brew install make
  • brew install cmake
  • brew install python
  • brew install php

Setup on Arch

  • sudo pacman -Syu
  • sudo pacman -S gcc
  • sudo pacman -S make
  • sudo pacman -S cmake
  • sudo pacman -S python
  • sudo pacman -S php

Usage

webserv requires a configuration file as an argument in order to run. The configuration file specifies the ports and roots for the server. pick a browser of your choice and visit the server's website by entering the address specified in the *.conf file (standard is localhost)
Project was extensively tested with Google Chrome and Chromium, it may be that other browsers behave differently in certain cases.

Configuration file

The configuration file is a plain text file that specifies the ports and roots for the server.
The file should contain one or more server blocks. Each server block begins with the server keyword and contains directives like in following example:

Click to expand server configuration
server {
server_name                     TurkmenianRacoons;
ip_address                      127.0.0.1;
port                            6969;
root                            html/;
allowed_methods                 GET PUT POST DELETE;
index                           index.html;
max_client_body_size            ;   
redirection                     google = https://www.google.com/;

    location /hering {
        allowed_methods	        GET POST DELETE;
        allowed_scripts         py = /usr/bin/python;
        allowed_scripts         php = /usr/bin/php;
        index                   start.py;
        cgi_path                ;
        directory_listing       true;
    }

    location /khan {
        root                    html/cgi/;
        allowed_methods         GET POST;
        allowed_scripts         py = /usr/bin/python;
        allowed_scripts         php = /usr/bin/php;
        index                   start.py;
        cgi_path                ;
        directory_listing       true;
    }

    location /hollandic_people {
        root                    html/cgi/;
        allowed_methods         GET POST;
        allowed_scripts         py = /usr/bin/python;
        allowed_scripts         php = /usr/bin/php;
        index                   start.py;
        cgi_path                ;
        directory_listing       true;
    }
}

Contributing

Contributions are welcome! If you find a bug or have an idea for a new feature, please create an issue or a pull request.

About

This project is about writing your ow HTTP server. You will be able to test it with an actual browser. HTTP is one of the most used protocols on the internet. Knowing its arcane will be useful, even if you won’t be working on a website.


Languages

Language:C++ 82.9%Language:HTML 8.2%Language:Python 3.6%Language:Shell 1.8%Language:CSS 1.5%Language:Makefile 1.0%Language:CMake 0.6%Language:PHP 0.4%Language:Dockerfile 0.1%