语法 | 默认 | 块 | 描述 |
---|---|---|---|
absolute_redirect on ? off; | on | http, server, location | 绝对路径 |
aio on ? off | threads[=pool]; | off | http, server, location |
aio_write on ? off; | http, server, location | ||
alias path; | — | location | |
chunked_transfer_encoding on ? off; | on | http, server, location | 块传输 |
client_body_buffer_size size; | 8k?16k | http, server, location | 请求的buffer |
client_body_in_file_only on ? clean ? off; | off | http, server, location | 是否将请求保存到文件,debug使用 |
client_body_in_single_buffer on ? off; | off | http, server, location | 是否将请求保存在buffer中 |
client_body_temp_path path [level1 [level2 [level3]]]; | client_body_temp | http, server, location | 临时存放请求的文件 |
client_body_timeout time; | 60s | http, server, location | 读取请求体的超时时间 |
client_header_buffer_size size; | 1k | http, server | 请求头的buffer |
client_header_timeout time; | 60s | http, server | 请求头的超时时间 |
client_max_body_size size; | 1m | http, server, location | 请求体大小的上限 |
connection_pool_size size; | 256?512 | http, server | 每个连接的内存空间大小 |
default_type mime-type; | text/plain | http, server, location | 相应的MIME类型 |
directio size ? off; | off | http, server, location | ? |
directio_alignment size; | 512 | http, server, location | ? |
disable_symlinks off; | off | http, server, location | ? |
error_page code … [=[response]] uri; | — | http, server, location, if in location | 错误页面显示 |
etag on ? off; | on | http, server, location | ? |
http { … } | — | main | |
if_modified_since off ? exact ? before; | exact | http, server, location | Specifies how to compare modification |
ignore_invalid_headers on ? off; | on | http, server | ? |
internal; | — | location | ?? |
keepalive_disable none ? browser …; | msie6 | http, server, location? | |
keepalive_requests number; | 100 | http, server, location | ? |
keepalive_timeout timeout [header_timeout]; | 75s | http, server, location | |
large_client_header_buffers number size; | 4 8k | http, server | |
limit_except method … { … } | — | location | |
limit_rate rate; | 0 | http, server, location, if in location | |
limit_rate_after size; | 0 | http, server, location, if in location | |
lingering_close off ? on ? always; | on | http, server, location | |
lingering_time time; | 30s | http, server, location | |
lingering_timeout time; | 5s | http, server, location | |
listen address[:port] | *:80 | server | 监听端口 |
location [ = ~ ~* ^~ ] uri { ... } | — | server, location | |
log_not_found on ? off; | on | http, server, location | |
log_subrequest on ? off; | off | http, server, location | |
max_ranges number; | — | http, server, location | |
merge_slashes on ? off; | on | http, server | |
msie_padding on ? off; | on | http, server, location | |
msie_refresh on ? off; | off | http, server, location | |
open_file_cache off; | off | http, server, location | |
open_file_cache_errors on ? off; | off | http, server, location | |
open_file_cache_min_uses number; | 1 | http, server, location | |
open_file_cache_valid time; | 60s | http, server, location | |
output_buffers number size; | 2 32k | http, server, location | |
port_in_redirect on ? off; | on | http, server, location | |
postpone_output size; | 1460 | http, server, location | |
read_ahead size; | 0 | http, server, location | |
recursive_error_pages on ? off; | off | http, server, location | |
request_pool_size size; | 4k | http, server | |
reset_timedout_connection on ? off; | off | http, server, location | |
resolver address … [valid=time] [ipv6=on | off] [status_zone=zone]; | — | http, server, location |
resolver_timeout time; | 30s | http, server, location | |
root path; | html | http, server, location, if in location | |
satisfy all ? any; | all | http, server, location | |
send_lowat size; | 0 | http, server, location | |
send_timeout time; | 60s | http, server, location | |
sendfile on ? off; | off | http, server, location, if in location | |
sendfile_max_chunk size; | 0 | http, server, location | |
server { … } | - | http | |
server_name name …; | “” | server | 虚拟服务 |
server_name_in_redirect on ? off; | off | http, server, location | |
server_names_hash_bucket_size size; | 32?64?128 | http | |
server_names_hash_max_size size; | 512 | http | |
server_tokens on ? off ? build ? string; | on | http, server, location | |
subrequest_output_buffer_size size; | 4k?8k | http, server, location | |
tcp_nodelay on ? off; | on | http, server, location | |
tcp_nopush on ? off; | off | http, server, location | |
try_files file … uri; | — | server, location | |
types { … } | |||
types_hash_bucket_size size; | |||
types_hash_max_size size; | |||
underscores_in_headers on ? off; | |||
variables_hash_bucket_size size; | |||
variables_hash_max_size size; |
alias root
location /i/ {
alias /data/w3/images/;
}
on request of “/i/top.gif”, the file /data/w3/images/top.gif will be sent.
location /i/ {
root /data/w3;
}
The /data/w3/i/top.gif file will be sent in response to the “/i/top.gif” request.
error
error_page 404 /404.html;
error_page 500 502 503 504 /50x.html;
limit_except
limit_except GET {
allow 192.168.1.0/32;
deny all;
}
listen
listen 127.0.0.1:8000;
listen 127.0.0.1;
listen 8000;
listen *:8000;
listen localhost:8000;
If only address is given, the port 80 is used.
The ssl parameter specifying that all connections accepted on this port should work in SSL mode
location
server_name
反向代理的目标,可以是域名,可以是ip
https://www.jianshu.com/p/181872fd4de3
参考:
http://nginx.org/en/docs/http/ngx_http_core_module.html