黑马程序员技术交流社区

标题: 【杭州校区】Nginx基本属性配置详解 [打印本页]

作者: 小江哥    时间: 2019-10-23 17:30
标题: 【杭州校区】Nginx基本属性配置详解
1. Nginx服务的基本配置1.1 用于调试进程和定位问题的配置项1.2 正常运行的配置项1.3 优化性能的配置项1.4 事件类配置项2. http核心模块配置2.1 监听端口listen address:port[default(deprecated)|default_server|[backlog=num|rcvbuf=size|sndbuf=size|accept_filter=filter|deferred|bind|ipv6only=[on|off]|ssl]]2.2 主机名称语法:server_name name [...];默认:server_name "";配置块:server2.3 server_names_hash_bucket_size语法:server_names_hash_bucket_size size;默认:server_names_hash_bucket_size 32|64|128;配置块:http、server、location2.4 server_names_hash_max_size语法:server_names_hash_max_size size;默认:server_names_hash_max_size 512;配置块:http、server、location2.5 重定向主机名称的处理语法:server_name_in_redirect on|off;默认:server_name_in_redirect on;配置块:http、server或者location2.6 location语法:location [=|~|~*|^~|@] /uri/{...}配置块:server3. 文件路径的定义3.1 以root方式设置资源路径语法:root path;默认:root html;配置块:http、server、locationo、if3.2 以alias方式设置资源文件语法:alias path;配置块:location;3.3 访问首页语法:index file...;默认:index index.html;配置块:http、server、location3.4 根据http返回码重定向页面语法:error_page code[code...][=|=answer-code]uri|@named_location配置块:http、server、location、if3.5 是否支持递归的使用error_page语法:recursive_error_pages [on|off];默认:recursive_error_pages off;配置块:http、server、location;3.6 try_files语法:try_files path1[path2]uri;配置块:server、location4. 内存及磁盘资源的分配4.1 http包体只存储到磁盘文件中语法:client_body_in_file_only on|clean|off;默认:client_body_in_file_only off;配置块:http、server、location4.2 http包体尽量写入到一个内存buffer中语法:client_body_in_single_buffer on|off;默认:client_body_in_single_buffer off;配置块:http、server、location4.3 存储http头部的内存buffer大小语法:client_header_buffer_size size;默认:client_header_buffer_size 1k;配置块:http、server4.4 存储超大http头部的内存buffer大小语法:large_client_header_buffers number size;默认:large_client_header_buffers 48k;配置块:http、server4.5 存储http包体的内存buffer的大小语法:client_body_buffer_size size;默认:client_body_buffer_size 8k/16k;配置块:http、server、location4.6 http包体的临时存放目录语法:client_body_temp_path dir-path[level1[level2[level3]]]默认:client_body_temp_path client_body_temp;配置块:http、server、location4.7 connection_pool_size语法:connection_pool_size size;默认:connection_pool_size 256;配置块:http、server4.8 request_pool_size语法:request_pool_size size;默认:request_pool_size 4k;配置块:http、server5. 网络连接的设置5.1 读取http头部的超时时间语法:client_header_timeout time(默认单位:秒);默认:client_header_timeout 60;配置块:http、server、location5.2 读取http包体的超时时间语法:client_body_timeout time(默认单位:秒);默认:client_body_timeout 60;配置块:http、server、location5.3 发送响应的超时时间语法:send_timeout time;默认:send_timeout 60;配置块:http、server、location5.4 reset_timeout_connection语法:reset_timeout_connection on|off;默认:reset_timeout_connection off;配置块:http、server、location5.5 lingering_close语法:lingering_close off|on|always;默认:lingering_close on;配置块:http、server、location5.6 lingering_time语法:lingering_time time;默认:lingering_time 30s;配置块:http、server、location5.7 lingering_timeout语法:lingering_timeout time;默认:lingering_timeout 5s;配置块:http、server、location5.8 对某些浏览器禁用keepalive功能语法:keepalive_disable [msie6|safari|none]...默认:keepalive_disablemsie6 safari配置块:http、server、location5.9 keepalive超时时间语法:keepalive_timeout time(默认单位:秒);默认:keepalive_timeout 75;配置块:http、server、location5.10 keepalive长连接上能够承载的最大请求数语法:keepalive_requests n;默认:keepalive_requests 100;配置块:http、server、location5.11 tcp_nodelay语法:tcp_nodelay on|off;默认:tcp_nodelay on;配置块:http、server、location5.12 tcp_nopush语法:tcp_nopush on|off;默认:tcp_nopush off;配置块:http、server、location6. MIME类型的设置6.1 MIME type与文件扩展的映射语法:type {...};配置块:http、server、location6.2 默认MIME type语法:default_type MIME-type;默认:default_type text/plain;配置块:http、server、location6.3 types_hash_bucket_size语法:types_hash_max_size size;默认:types_hash_max_size 1024;配置块:http、server、location6.4 types_hash_max_size语法:types_hash_max_size size;默认:types_hash_max_size 1024;配置块:http、server、location7. 对客户端请求的限制7.1 按http方法名限制用户请求语法:limit_except method...{...}配置块:location7.2 http请求包体的最大值语法:client_max_body_size size;默认:client_max_body_size 1m;配置块:http、server、location7.3 对请求的限速语法:limit_rate speed;默认:limit_rate 0;配置块:http、server、location、if7.4 limit_rate_after语法:limit_rate_after time;默认:limit_rate_after 1m;配置块:http、server、location、if8. 文件操作的优化8.1 sendfile系统调用语法:sendfile on|off;默认:sendfile off;配置块:http、server、location8.2 AIO系统调用语法:aio on|off;默认:aio off;配置块:http、server、location8.3 directio语法:directio size|off;默认:directio off;配置块:http、server、location8.4 directio_alignment语法:directio_alignment size;默认:directio_alignment 512;配置块:http、server、location8.5 打开文件缓存语法:open_file_cache max=N[inactive=time]|off;默认:open_file_cache off;配置块:http、server、location8.6 是否缓存打开文件错误的信息语法:open_file_cache_errors on|off;默认:open_file_cache_errors off;配置块:http、server、location8.7 不被淘汰的最小访问次数语法:open_file_cache_min_uses number;默认:open_file_cache_min_uses 1;配置块:http、server、location8.8 检验缓存中元素有效性的频率语法:open_file_cache_valid time;默认:open_file_cahce_valid 60s;配置块:http、server、location9. 对客户端请求的特殊处理9.1 忽略不合法的http头部语法:ignore_invalid_headers on|off;默认:ignore_invalid_headers on;配置块:http、server9.2 http头部是否允许下划线语法:underscores_in_headers on|off;默认:underscores_in_headers off;配置块:http、server9.3 对If-Modified-Since头部的处理策略语法:if_modified_since [off|exact|before];默认:if_modified_since exact;配置块:http、server、location9.4 文件未找到时是否返回error日志语法:log_not_found on|off;默认:log_not_found on;配置块:http、server、location9.5 merge_slashes语法:merge_slashes on|off;默认:merge_slashes on;配置块:http、server、location9.6 DNS解析地址语法:resolver address...;配置块:http、server、location9.7 DNS解析的超时时间语法:resolver_timeout time;默认:resolver_timeout 30s;配置块:http、server、location9.8 返回错误页面时是否在server中注明nginx版本语法:server_tokens on|off;默认:server_tokens on;配置块:http、server、location





欢迎光临 黑马程序员技术交流社区 (http://bbs.itheima.com/) 黑马程序员IT技术论坛 X3.2