root和alisa的区别
root可以把后面的url完整的映射进文件路径中, 而alias只会将location后的url映射到文件路径
将会生成3个变量:
- request_filename 访问文件的完整路径
- document_root 根据root/alias生成的文件夹路径
- realpath_root 将document_root中的软连接换车真实路径
静态文件返回的content-type
1 2 3 4 5 6 7 8 9 10 11 12
| Syntax: types { ... } Default: types { text/html html; image/gif gif; image/jpeg jpg; } Context: http, server, location Syntax: default_type mime-type; Default: default_type text/plain; Context: http, server, location Syntax: types_hash_bucket_size size; Default: types_hash_bucket_size 64; Context: http, server, location Syntax: types_hash_max_size size; Default: types_hash_max_size 1024; Context: http, server, location
|
重定向跳转的域名
1 2 3 4 5 6 7 8 9 10 11 12 13 14
| Syntax: server_name_in_redirect on | off; Default: server_name_in_redirect off; Context: http, server, location #在返回的location中添加server_name设定的主域名
Syntax: port_in_redirect on | off; Default: port_in_redirect on; Context: http, server, location
Syntax: absolute_redirect on | off; Default: absolute_redirect on; Context: http, server, location ##在返回的信息中location, 添加了访问时的域名 , 如果在访问的头部信息中有host , 则把访问的域名替换成host携带的信息 , 比如curl http://localhost:8080 , 则在返回的信息中的location 添加http://localhost:8080 , 如果curl -H 'aaa' http://localhost:8080 则在返回的信息中的location添加: Location: http://aaa:8080
|
index和autoindex
1 2 3
| Syntax: index file ...; Default: index index.html; Context: http, server, location
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
| Syntax: autoindex on | off; Default: autoindex off; Context: http, server, location
Syntax: autoindex_exact_size on | off; Default: autoindex_exact_size on; Context: http, server, location
Syntax: autoindex_format html | xml | json | jsonp; Default: autoindex_format html; Context: http, server, location
Syntax: autoindex_localtime on | off; Default: autoindex_localtime off; Context: http, server, location
|
当url以 / 结尾时候, 尝试以html/xml/json/jsonp等格式返回root/alias指向的目录的目录结构
concat模块
ngx_http_concat_module模块的功能是当页面需要访问多个小文件时候 , 把他们的内容合并到一次http响应中返回 , 提升性能 , 他的地址是Tengine(https://github.com/alibaba/nginx-http-concat)
如何使用:
在url后面跟上?? , 后通过多个, 逗号分隔文件 , 如果有参数 ,则在最后添加?添加
比如:https://g.alicdn.com/??kissy/k/6.2.4/seed-min.js,kg/global-util/1.0.7/
指令
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
| concat:on | off default:concat off Context:http, server, location
concat_types:MIME types Default:concat_types: text/css application/x-javascript Context:http, server, location
concat_unique:on | off Default: concat_unique on Context: http, server, location
concat_max_files:numberp Default:concat_max_files 10 Context: http, server, location
concat_delimiter:string Default:NONE Context: http, server, locatione
concat_ignore_file_error:on | off Default:off Context:http, server, location
|