Skip to content

Configuration file

Daniel-Alessandros Atack edited this page Jun 22, 2022 · 57 revisions

Rules

A server block must have a location block.

Server and location blocks must be properly opened and closed with brackets {}.

A server block can't contain a server block, likewise, a location block can't contain a location block.

Error_page, location, root, index, rewrite and cgi_path string arguments go through a verify_url function only allowing http(s):// or absolute paths

If a server has multiple locations pointing to the same path, i.e: location / {} location / {}, only the first will be used.

After the initial parsing, servers with a same host::port are bundled up together; this is so we only open one socket per host::port.

Syntax

Tables Arguments Scope Purpose Default Value
server_name = string ... ; server Setup the names of the server which determine which block is used for a given request webserv (42) v0.1-dev
host = string ; server Setup the host of the server 127.0.0.1
port = int ; server Setups the port listened by the server; has to be minimum 1024 and maximum 65535 3000
index = string ... ; server, location Defines the index file’s name -
root string ; server, location Setups the root path . for servers
error_pages int ... = string server, location Setups the error pages -
read_timeout = int ; server Customizes the timeout reading a request -1
client_header_size = int ; server Client HTTP Request header size limit 2048
server_body_size = int ; server Limits the size of the request body by the server 2048
body_max_size = int ; server, location Sets buffer size for reading client request body, has to be 0 or greater 2048
methods = string ... ; location Setups a list of HTTP methods accepted by the location GET, HEAD
rewrite int string string ; location Setups an HTTP redirection with a redirect_code, url, redirect_url; throws an error if the redirect_code isn't 3xx -
auto_index on/off ; location Enables directory listing off
cgi_enable on/off ; location Enables the use of CGI off
cgi_extension = string ... ; location For which file extensions CGI is enabled -
cgi_timeout = int ; location Customizes the timeout for a CGI execution -1
cgi_path = string ; location Defines the path/name of the CGI executable -
send_file on/off ; location Enables direct copying data from one file descriptor to another instead of writing to a buffer first off
file_limit = int ; location Customizes the maximum size of a file in megabytes 5000
max_amount_of_request = int ; server Customizes the maximum amount of requests handled at the same time by the server 100
max_uri_size = int ; server Customizes the maximum size of the URI size handled by the server, throws an error if inferior to 30 50
run_file_path = string ; server /run/webserv/
chunk_head_limit = int ; server,location 20
chunk_body_limit = int ; server, location 100

Clone this wiki locally