Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

pabloocg/webserv

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

License


Webserv

This is when you finally understand why a url starts with HTTP
Explore the docs »

Table of Contents
  1. About The Project
  2. Getting Started
  3. Usage
  4. License
  5. Contact

About The Project

This project is here to make you write your own HTTP server. You will follow the real HTTP RFC and you will be able to test it with a real browser. HTTP is one of the most used protocol on internet. Knowing its arcane will be useful, even if you won’t be working on a website.


Madatory Part

Program name webserv
Makefile yes
External functs. malloc, free, write, open, read, close, mkdir,rmdir, unlink, fork, wait, waitpid, wait3, wait4,signal, kill, exit, getcwd, chdir, stat, lstat,fstat, lseek, opendir, readdir, closedir, execve,dup, dup2, pipe, strerror, errno, gettimeofday,strptime, strftime, usleep, select, socket, accept,listen, send, recv, bind, connect, inet_addr,setsockopt, getsockname, fcntl
Libft authorized yes
Description Write a HTTP server in C++

Compliant with the rfc 7230 to 7235 (http 1.1) but only the following headers are implemented:

  • Accept-Charsets, Accept-Language, Allow, Authorization, Content-Language, Content-Length, Content-Location, Content-Type, Date, Host, Last-Modified, Location, Referer, Retry-After, Server, Transfer-Encoding, User-Agent, WWW-Authenticate.

Getting Started

Installation

  1. Clone the repository
    git clone https://github.com/pabloocg/webserv.git
  2. Enter the repository and run make
    cd webserv && make

Configuration

The program receives as argument a configuration file with the specifications to be launched.
If no configuration file is offered, a default configuration file is taken.
The configuration file is very similar to the nginx configuration. The main parameters to configure and launch a server are:

  1. Choose the port and host of each "server"

    listen       8080;
    server_addr 127.0.0.1;
    
  2. Setup the server_names or not

    server_name  localhost;
    
  3. Setup custom error pages (if not specified, they are taken as the default.)

    error_page  404              error_pages/404.html;
    error_page  403              error_pages/403.html;
    error_page  401              error_pages/401.html;
    error_page  500 502 503 504  error_pages/50x.html;
    
  4. Setup routes with one or multiple of the following rules/configuration.

    location / {
        http_methods GET HEAD POST PUT OPTIONS DELETE;
        root   www/;
        index  index.html index.htm;
        upload on;
        path_upload www/uploads;
        auth_basic off;
        languages en-US es-es;
    }
    
    location /test/ {
        http_methods GET HEAD;
        root   www/test/;
        index  test.html index.html;
        auth_basic "Admin credentials";
        auth_basic_user_file auth/.htpasswd;
    }
    
  5. Configure a CGI.

    location ~ \.php$ {
        http_methods    GET POST;
        cgi_exec        /path-to/bin/php-cgi;
        root            www/;
        index           index.php;
    }
    

You can see different examples of configuration files here.

Usage

The configuration file provided as argument is optional.

./webserv tests/example.conf

Now with your favourite web browser you can access the address and port where you have set the server.

License

Distributed under the GNU GPLv3. See LICENSE for more information.

Contact

Pablo Cuadrado García
Linkedin - pablocuadrado97@gmail.com

About

HTTP1.1 web server written in C++

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published