-
Notifications
You must be signed in to change notification settings - Fork 0
Configuration file
Daniel-Alessandros Atack edited this page Jun 14, 2022
·
57 revisions
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.
An error is thrown if there is at least 2 servers with the same host and defined ports
Example :
Server "127.0.0.1" listens to 3000,3020,3040
A second Server "127.0.0.1" listens to 4000,3020,4020
-> Same server_name and one shared port hence Error thrown
Error_page, location, root, index, rewrite and cgi_path string arguments go through a verify_url function only allowing http(s):// or absolute paths
| Tables | Arguments | Scope | Purpose |
|---|---|---|---|
| server_name | = string ; | server | Setup the name of the server which determine which block is used for a given request, by default "webserv (42) v0.1-dev" |
| host | = string ; | server | Setup the host of the server, by default "127.0.0.1" |
| port | = int ; | server | Setups the port listened by the server; by default 3000; has to be minimum 1024 and maximum 65535 |
| index | = string ... ; | server, location | Defines the index file’s name |
| root | string ; | server, location | Setups the root path, by default "." for servers |
| error_pages | int ... = string | server, location | Setups the error pages |
| read_timeout | = int ; | server | Customizes the timeout reading a request, by default -1 |
| client_header_size | = int ; | server | Client HTTP Request header size limit, 2048 by default |
| server_body_size | = int ; | server | Limits the size of the request body by the server, 2048 by default |
| body_max_size | = int ; | server, location | Sets buffer size for reading client request body, 2048 by default, has to be 0 or greater |
| methods | = string ... ; | location | Setups a list of HTTP methods accepted by the location, empty by default |
| 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, by default off |
| cgi_enable | on/off ; | location | Enables the use of CGI, by default off |
| cgi_extension | = string ... ; | location | For which file extensions CGI is enabled |
| cgi_timeout | = int ; | location | Customizes the timeout for a CGI execution, by default -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, by default off |
| file_limit | = int ; | location | Customizes the maximum size of a file in megabytes, by default 5000 |
| max_amount_of_request | = int ; | server | Customizes the maximum amount of requests handled at the same time by the server, by default 100 |
| max_uri_size | = int ; | server | Customizes the maximum size of the URI size handled by the server, by default 50, throws an error if inferior to 30 |