###Directives
####Main directive
- server
####Server level directives
- listen
- server_name
- index
- c_body_limit
- root
- error_page
- location
- host
####Location level directives
- limit_except
- root
- index
- error_page
- return
| Directive | Description | Usage |
|---|---|---|
server |
Configuration block for each server | server {listen 8080; } |
listen |
The port number to which the server listens to. Only one listen directive per server block. |
listen 8080; |
server_name |
The name of the server. Only one server_name directive per server block. A server block should have at least one location block, eg: root ("/") |
server_name abc; |
index |
The name of the index file. Only one index directive per server block or location block. |
index index.html; |
c_body_limit |
The client body limit in MB. Default value is 1 MB. Server level c_body_limit is inherited by locations when the location does not specify a c_body_limit directive. Only one c_body_limit directive per server block or location block. | c_body_limit 50; |
root |
The root directory. The server level root value is inherited by the locations when the location does not have a root directive. Location level root does not stack up with server level when both has root directives. Location root replaces the server root entirely for that location. Only one index directive per server block or location block. | root www/; |
error_page |
The path to error page and the relevant error code. The server level error_page values are inherited by the locations when the location does not have the error_page directive for a specific error code. Location level error_page directives are written at the end of location directive. Server level error_page directives are written at the end of the server directive, after writing all the location blocks. Multiple error_page directives are possible per server block or location block. | error_page [error_code] [path_to_error_html]; error_page 404 /404.html; |
location |
||
host |
The ip address in IPV4 or by name (localhost) | host localhost; |
return |
HTTP redirecting to URL or location block | return [return_code] [URL with schema]; return [return_code] [URI of location]; |