Nginx中文文档
DocsHome
  • 贡献导引
  • 介绍
    • 安装 nginx
    • 从源码构建 nginx
    • 初学者指南
    • 管理指南
    • 控制 nginx
    • 连接处理方式
    • 设置哈希
    • 调试日志
    • 记录日志到 syslog
    • 配置文件度量单位
    • 命令行参数
    • Windows 下的 nginx
    • QUIC 和 HTTP/3 支持
    • nginx 如何处理请求
    • 服务器名称
    • 使用 nginx 作为 HTTP 负载均衡器
    • 配置 HTTPS 服务器
    • nginx 如何处理 TCP/UDP 会话
    • 关于 nginScript
  • 其他
    • Linux 软件包
  • How-To
    • 在 Win32 平台上使用 Visual C 构建 nginx
    • 设置 Amazon EC2 的 Nginx Plus 环境
    • 使用 DTrace pid 提供程序调试 nginx
    • 转换重写规则
    • WebSocket 代理
  • 开发
    • 贡献指南
    • 开发指南
  • 模块参考
  • 核心功能
    • HTTP
      • ngx_http_core_module
      • ngx_http_access_module
      • ngx_http_addition_module
      • ngx_http_api_module
      • ngx_http_auth_basic_module
      • ngx_http_auth_jwt_module
      • ngx_http_auth_request_module
      • ngx_http_autoindex_module
      • ngx_http_browser_module
      • ngx_http_charset_module
      • ngx_http_dav_module
      • ngx_http_empty_gif_module
      • ngx_http_f4f_module
      • ngx_http_fastcgi_module
      • ngx_http_flv_module
      • ngx_http_geo_module
      • ngx_http_geoip_module
      • ngx_http_grpc_module
      • ngx_http_gunzip_module
      • ngx_http_gzip_module
      • ngx_http_gzip_static_module
      • ngx_http_headers_module
      • ngx_http_hls_module
      • ngx_http_image_filter_module
      • ngx_http_index_module
      • ngx_http_js_module
      • ngx_http_keyval_module
      • ngx_http_limit_conn_module
      • ngx_http_limit_req_module
      • ngx_http_log_module
      • ngx_http_map_module
      • ngx_http_memcached_module
      • ngx_http_mirror_module
      • ngx_http_mp4_module
      • ngx_http_perl_module
      • ngx_http_proxy_module
      • ngx_http_random_index_module
      • ngx_http_realip_module
      • ngx_http_referer_module
      • ngx_http_rewrite_module
      • ngx_http_scgi_module
      • ngx_http_secure_link_module
      • ngx_http_session_log_module
      • ngx_http_slice_module
      • ngx_http_spdy_module(过时)
      • ngx_http_split_clients_module
      • ngx_http_ssi_module
      • ngx_http_ssl_module
      • ngx_http_status_module(过时)
      • ngx_http_stub_status_module
      • ngx_http_sub_module
      • ngx_http_upstream_module
      • ngx_http_upstream_conf_module
      • ngx_http_upstream_hc_module
      • ngx_http_userid_module
      • ngx_http_uwsgi_module
      • ngx_http_v2_module
      • ngx_http_xslt_module
    • Mail
      • ngx_mail_core_module
      • ngx_mail_auth_http_module
      • ngx_mail_proxy_module
      • ngx_mail_ssl_module
      • ngx_mail_imap_module
      • ngx_mail_pop3_module
      • ngx_mail_smtp_module
    • Stream
      • ngx_stream_core_module
      • ngx_stream_access_module
      • ngx_stream_geo_module
      • ngx_stream_geoip_module
      • ngx_stream_js_module
      • ngx_stream_keyval_module
      • ngx_stream_limit_conn_module
      • ngx_stream_log_module
      • ngx_stream_map_module
      • ngx_stream_proxy_module
      • ngx_stream_realip_module
      • ngx_stream_return_module
      • ngx_stream_split_clients_module
      • ngx_stream_ssl_module
      • ngx_stream_ssl_preread_module
      • ngx_stream_upstream_module
      • ngx_stream_upstream_hc_module
      • ngx_stream_zone_sync_module
    • 其他
      • ngx_google_perftools_module
由 GitBook 提供支持
在本页
  • 已知问题
  • 示例配置
  • 指令
  • http2_body_preread_size
  • http2_chunk_size
  • http2_idle_timeout
  • http2_max_concurrent_pushes
  • http2_max_concurrent_streams
  • http2_max_field_size
  • http2_max_header_size
  • http2_max_requests
  • http2_push
  • http2_push_preload
  • http2_recv_buffer_size
  • http2_recv_timeout
  • 内嵌变量
  • 原文档
  1. 核心功能
  2. HTTP

ngx_http_v2_module

上一页ngx_http_uwsgi_module下一页ngx_http_xslt_module

最后更新于5年前

ngx_http_v2_module 模块(1.9.5)提供对 的支持并取代了 模块。

默认不构建此模块,可使用 --with-http_v2_module 配置参数启用。

已知问题

示例配置

server {
    listen 443 ssl http2;

    ssl_certificate server.crt;
    ssl_certificate_key server.key;
}

指令

http2_body_preread_size

-

说明

语法

http2_body_preread_size size;

默认

http2_body_preread_size 64k;

上下文

http、server

提示

该指令在 1.11.0 版本中出现

设置在开始处理之前可能被保存的请求体中的每个请求的缓冲区大小(size)。

http2_chunk_size

-

说明

语法

http2_chunk_size size;

默认

http2_chunk_size 8k;

上下文

http、server、location

http2_idle_timeout

-

说明

语法

http2_idle_timeout time;

默认

http2_idle_timeout 3m;

上下文

http、server

设置连接关闭后的不活动超时时间。

http2_max_concurrent_pushes

-

说明

语法

http2_max_concurrent_pushes number;

默认

http2_max_concurrent_pushes 10;

上下文

http、server

提示

该指令在 1.13.9 版本中出现

http2_max_concurrent_streams

-

说明

语法

http2_max_concurrent_streams number;

默认

http2_max_concurrent_streams 128;

上下文

http、server

设置一个连接的最大并发 HTTP/2 流数量。

http2_max_field_size

-

说明

语法

http2_max_field_size size;

默认

http2_max_field_size 4k;

上下文

http、server

http2_max_header_size

-

说明

语法

http2_max_header_size size;

默认

http2_max_header_size 16k;

上下文

http、server

http2_max_requests

-

说明

语法

http2_max_requests number;

默认

http2_max_requests 1000;

上下文

http、server

提示

该指令在 1.11.6 版本中出现

要释放每个连接的内存分配,必须定期关闭连接。因此,设置过多的最大请求数可能会导致内存使用过多,因此不建议这样做。

http2_push

-

说明

语法

http2_push uri | off;

默认

http2_push off;

上下文

http、server、location

提示

该指令在 1.13.9 版本中出现

http2_push /static/css/main.css;

uri 值可以包含变量。

可以在同一配置级别上指定几个 http2_push 指令。off 参数取消从其他配置级别继承的 http2_push 指令的作用。

http2_push_preload

-

说明

语法

http2_push_preload on | off;

默认

http2_push_preload off;

上下文

http、server、location

提示

该指令在 1.13.9 版本中出现

http2_recv_buffer_size

-

说明

语法

http2_recv_buffer_size size;

默认

http2_recv_buffer_size 256k;

上下文

http

http2_recv_timeout

-

说明

语法

http2_recv_timeout time;

默认

http2_recv_timeout 30s;

上下文

http、server

设置超时时间以从客户端获得更多数据,然后关闭连接。

内嵌变量

ngx_http_userid_module 模块支持以下内嵌变量:

  • $http2

    协商的协议标识符:h2 用于 TLS HTTP/2,h2c 用于在明文 TCP HTTP/2,否则为空字符串。

原文档

在 1.9.14 版本之前,无论 、、 和 指令值如何设置,都无法禁用客户端请求体缓冲。

请注意,通过 TLS 接受 HTTP/2 连接需要「应用层协议协商」(Application-Layer Protocol Negotiation,ALPN)TLS 扩展支持,该支持仅在 1.0.2 版本之后可用。使用「次协议协商」(Next Protocol Negotiation,NPN)TLS 扩展(自 OpenSSL 1.0.1 版本起可用)不能保证生效。

另外,如果 指令设置为 on 值,则应将密码配置为符合 并由客户端支持。

设置响应体切片的最大大小(size)。值太低会导致更高的开销。由于 ,过高的值会破坏优先级。

限制一个连接的最大并发请求数。

限制 压缩的请求头字段的最大大小(size)。该限制同样适用于字段名和值。请注意,如果使用了霍夫曼编码,则解压缩后的字段名和值字符串的实际大小可能会更大。对于大多数请求,默认限制应该足够。

限制 解压缩后整个请求头列表的最大大小(size)。对于大多数请求,默认限制应该足够。

设置可以通过一个 HTTP/2 连接提供服务的最大请求数量(number)(包括请求),之后下一个客户端请求将导致连接关闭以及需要建立新连接。

抢先向指定的 uri 发送()请求以及对原始请求响应。仅处理有绝对路径的相对 URI,例如:

启用将 Link 响应头字段中指定的自动转换为请求的功能。

设置每个输入缓冲区的大小(size)。

OpenSSL
HOL 阻塞
HPACK
HPACK
推送
预加载链接
推送
http://nginx.org/en/docs/http/ngx_http_v2_module.html
HTTP/2
ngx_http_spdy_module
已知问题
示例配置
指令
http2_body_preread_size
http2_chunk_size
http2_idle_timeout
http2_max_concurrent_pushes
http2_max_concurrent_streams
http2_max_field_size
http2_max_header_size
http2_max_requests
http2_push
http2_push_preload
http2_recv_buffer_size
http2_recv_timeout
内嵌变量
推送
推送
RFC 7540 中的附录 A 黑名单
工作进程
proxy_request_buffering
ssl_prefer_server_ciphers
scgi_request_buffering
fastcgi_request_buffering
uwsgi_request_buffering