1、本文不讲解'HTTP2'的知识
2、只讲解nginx中如何'配置'HTTP2
①Preconditions _
1、openssl的版本必须在'1.0.2e+'及以上
2、开启'https加密',目前http2.0只支持'开启了https'的网站
编译选项:--with-http_ssl_module --with-http_v2_module
特点:因为HTTP2.0采用HTTPS,HTTPS基于'SSL/TLS'的
3、nginx版本必须在'1.9.5+'以上,用 http_v2_module 模块'替换'了 ngx_http_spdy_module
Cipher suites supported by http2.0
HTTP/2协议'使用TLS 1.2+'版本作为'安全'加密层
② http2
注意: nginx'1.25.1'才支持'http2'独立配置,此时'不是'端口级别
③ listen http2 parameters
1、listen的'http2参数'是'端口'级别
2、常见'案例'
listen 80 http2; --> 该端口'只支持http2','不向下'兼容
listen 443 ssl http2 --> 该listen 也'兼容http1.1',注意'ssl'和'http2'的顺序
3、nginx '1.25.1'之'前'的版本'只能'通过listen配置'http2'参数,'端口'级别
http2 parameter port level nginx cannot enable HTTP2 according to the virtual host: error report
④ $http2
How to get http2 header in nginx
⑤Why does the browser know that it needs to use the h2 protocol to request?
⑥ How to configure http2 in nginx
说明: 省略'编译'过程
./configure --with-http_v2_module --with-http_ssl_module
注意: 最好'保留'原来'nginx -V'的编译参数
nginx -V --> 可以确定'版本'和安装了'某个'模块
nginx compile and install http2
1、nginx'配置'
add_header X-Protocol '$http2 $ssl_cipher $ssl_protocol $server_protocol';
2、'报文'分析
⑦Supplement _
1、nginx作为'反向代理'不支持http2
2、nginx作为服务端如果'不支持http2',协议降级为'http1.1'
3、http2'会'让响应头'小写'
注意: 业务侧建议'不要区分'大小写
备注:HTTP1.1 返回的Header里,网络层会转化为'首字母大写'形式进行返回
4、HTTP/2 请求的客户端应该使用 ':authority'伪字段而'不是Host字段'
5、关注curl和浏览器'版本'对'http2'的支持
HTTP/2 constrains Header case browser to see if it supports http2
ngx.header.content_length = nil
RFC document http2 reference how nginx supports HTTP/2 protocol
proxy_ssl_server_name on 最'关键'的
也就是把主机名字传递给后端服务器,让对方服务器在'TLS握手'层面就可以收到host,便于打到具体的主机
+++++++++++ "正则" +++++++++++
1、PCRE是一个NFA正则引擎,不然不能提供完全与Perl一致的正则语法功能
2、但它同时也实现了DFA,只是满足'数学意义'上的正则