Skip to content

LayeredChoas/webserver

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

webserv

42 project, recoding our own web server in C++. A program capable of running an HTTP server, handling requests, and parsing configuration files. webserv is a HTTP/1.1 server written in C++98. It must be conditionnal compliant with RFC 7230 to 7235.

Usage

# Compile the sources
make
# Run the server
./webserv [config_file]

Configuration File

host : host ip address

sets configuration depending on the given uri.

port : listen ports (support multiple);

bind the given address to the port. if no address is given, binds 0.0.0.0.

server_name : server_name name ...;

sets names of a virtual server.

root : root path;

sets the directory for requests.

allowed_methods : allowed_methods: GET,POST,...

sets the allowed methods for the root.

error_page : error_page:[error code]:[error page path]

defines the URI that will be shown for the specified errors.

location : upload: / | /*.extension | /path/folder

defines the requests location.

autoindex : autoindex=on|off (default off)

enables or disables the directory listing output.

index : index file ...;

defines files that will be used as an index.

cgi : cgi_uri=uri;

defines a CGI binary that will be executed for the given extension.

limit_client_body : limit_client_body=number (default unlimited)

It sets the maximum allowed size of the client request body, specified in the “Content-Length” request header field.

Example

server
[
    host:0.0.0.0
    port:80
    port:22

    server_name:localhost
    allowed_methods:GET

    location:/
    {
        root=website
        default=index.html
        autoindex=on
    }

    error_page:401:website/error_page/401.html
    error_page:403:website/error_page/403.html

    location:/*.bla
    {
        allowed_methods=POST
        cgi_uri=/users/layeredchoas/test/
    }

    location:/dir
    {
        root=/users/layeredchoas
        default=TestFile
        autoindex=on
    }

    location:/autoindex
    {
        root=/users/layeredchoas/files
        default=nothing
        autoindex=on
    }

    location:/upload
    {
        root=/users/layeredchoas/upload_folder
        allowed_methods=GET,PUT,HEAD,POST
        limit_client_body=20
    }

    location:/methods
    {
        allowed_methods=HEAD
    }

    location:/private/
    {
        root=/goinfre/ayennoui/ybouddou/private
        default=payments
        access=/goinfre/ayennoui/ybouddou/private/.access.prv
    }

]

HTTP 1.1 (standard to follow) :

HTTP/1.1 (RFC 2616)

HTTP/1.1 : Message Syntax and Routing (RFC 7230)

HTTP/1.1 : Semantics and Content (RFC 7231)

HTTP/1.1 : Conditional Requests (RFC 7232)

HTTP/1.1 : Range Requests (RFC 7233)

HTTP/1.1 : Caching (RFC 7234)

HTTP/1.1 : Authentication (RFC 7235)

Other HTTP (legacy / future) :

HTTP/1.0 (RFC 1945)

HTTP/2 (RFC 7240)

HTTP/2 : Header Compression (RFC 7241)

FTP (RFC 959)

HTTP Header Syntax

HTTP Request Methods

HTTP Status Codes

HTTP Header Break Style

Select and non-blocking

Select

Non-blocking I/O

CGI

CGI : Getting Started

CGI 1.1 Documentation

About

Webserver c++

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published