Implement an HTTP server like NGINX
git clone [email protected]:ak0327/42_webserv.git
cd 42_webserv
make
./webserv [path_to_configuration_file.conf]
- If
path_to_configuration_file.conf
is omitted, read the default confconf/webserv.conf
- named:
<file_name>.conf
- placed in:
PJ_root/conf
-
block
http
server
location
-
directive
listen
server_name
error_page
client_max_body_size
rewrite or return
root
autoindex
index
limit_except
deny
allow
cgi_mode
cgi_extension
cgi_timeout
recv_timeout
send_timeout
keepalive_timeout
session_timeout
- http block
http_block = [ *(SP / LF) "http" 1*(SP / LF) "{" 1*(SP / LF) *server_block 1*(SP / LF) "}" 1*(SP / LF) ]
- server block
server_block = [ "server" 1*(SP / LF) "{" 1*(SP / LF) *location_block 1*(SP / LF) *directive_line 1*(SP / LF) "}" 1*(SP / LF) ]
- location block
location_block = [ "location" 1*(SP / LF) pattern URI 1*(SP / LF) "{" 1*(SP / LF) *directive_line 1*(SP / LF) "}" 1*(SP / LF) ] pattern = ("=" 1*SP / "^~" 1*SP / "")
- directive line
directive_line = directive 1*SP parameters *SP ";" parameters = parameter 1*(SP parameter)
- Grammar
SP
:LF
:\n
/
: or*X
: repeatX
zero or more timesn*X
: n or more repetitions ofX
."string"
: stringdirective
: directiveparameter
: parameter corresponding to the directive.
- Syntax
-
listen
"listen" ( address[:port] / port ) [default_server] ";"
- Default: listen *:80 | *:8000;
- Context: server
-
server_name
"server_name" name ... ";"
- Default: server_name "";
- Context: server
-
error_page
"error_page" code ... uri ";" 300 <= code <= 599; except 499
- Default: -
- Context: http, server, location, if in location
-
client_max_body_size
"client_max_body_size" size ";"
- Default: client_max_body_size 1m;
- Context: http, server, location
- Setting size to 0
- disables checking of client request body size
- If the size in a request exceeds the configured value
- the 413 (Request Entity Too Large) error is returned to the client
-
return
"return" code [text] ";"
- return code URL;
- return URL;
- Default: —
- Context: server, location, if
-
rewrite
"rewrite" regex replacement ";"
- Default: -
- Context: server, location, if
-
root
"root" path ";"
- Default: root html;
- Context: http, server, location, if in location
- https://nginx.org/en/docs/http/ngx_http_core_module.html#root
-
autoindex
"autoindex" on | off ";"
- Default: autoindex off;
- Context: http, server, location
-
index
"index" file ... ";"
- Default: index index.html;
- Context: http, server, location
-
- Ubuntu 22.04.2 LTS (ARM64)
- MacOS OS Ventura 13.5 (ARM64)
- HTTP Documentation
- HTTP 日本語訳
- MDN docs
- nginx
- Module ngx_http_core_module
- nginx開発ガイド
- システムプログラム (2022年)
- Michael Kerrisk, Linux プログラミングインタフェース(千住 治郎 訳), オライリージャパン
- 渋川 よしき, Real World HTTP, オライリージャパン
- 戸根 勤, ネットワークはなぜつながるのか 第2版, 日経BP社
- 前橋 和弥, 基礎からのWebアブリケーシヨン開発入門, 技術評論社
- Paul S.Hethmon, HTTP詳説(ファサード 訳), ピアソン・エデュケーション