[记录点滴]OpenResty 支持http v2的问题
时间:2022-07-24
本文章向大家介绍[记录点滴]OpenResty 支持http v2的问题,主要内容包括其使用实例、应用技巧、基本知识点总结和需要注意事项,具有一定的参考价值,需要的朋友可以参考一下。
[记录点滴]OpenResty 支持http v2的问题
0x00 摘要
记录一次OpenResty支持http v2的问题排查。
0x01 问题
错误现象:无法上传图片,后台log是http v2 not supported yet
。
以为是后台没有开启http v2,于是开始排查。
0x02 排查
nginx
nginx显示支持 v2
/usr/local/openresty/nginx/sbin/nginx -V
nginx version: openresty/1.11.2.3
built by gcc 4.8.5 20150623 (Red Hat 4.8.5-11) (GCC)
built with OpenSSL 1.0.2k 26 Jan 2017
TLS SNI support enabled
configure arguments: --prefix=/usr/local/openresty/nginx --with-cc-opt='-O2 -I/usr/local/openresty/zlib/include -I/usr/local/openresty/pcre/include -I/usr/local/openresty/openssl/include' --add-module=../ngx_devel_kit-0.3.0 --add-module=../echo-nginx-module-0.60 --add-module=../xss-nginx-module-0.05 --add-module=../ngx_coolkit-0.2rc3 --add-module=../set-misc-nginx-module-0.31 --add-module=../form-input-nginx-module-0.12 --add-module=../encrypted-session-nginx-module-0.06 --add-module=../srcache-nginx-module-0.31 --add-module=../ngx_lua-0.10.8 --add-module=../ngx_lua_upstream-0.06 --add-module=../headers-more-nginx-module-0.32 --add-module=../array-var-nginx-module-0.05 --add-module=../memc-nginx-module-0.18 --add-module=../redis2-nginx-module-0.14 --add-module=../redis-nginx-module-0.3.7 --with-ld-opt='-Wl,-rpath,/usr/local/openresty/luajit/lib -L/usr/local/openresty/zlib/lib -L/usr/local/openresty/pcre/lib -L/usr/local/openresty/openssl/lib -Wl,-rpath,/usr/local/openresty/zlib/lib:/usr/local/openresty/pcre/lib:/usr/local/openresty/openssl/lib' --with-pcre-jit --with-ipv6 --with-stream --with-stream_ssl_module --with-http_v2_module --without-mail_pop3_module --without-mail_imap_module --without-mail_smtp_module --with-http_stub_status_module --with-http_realip_module --with-http_addition_module --with-http_auth_request_module --with-http_secure_link_module --with-http_random_index_module --with-http_gzip_static_module --with-http_sub_module --with-http_dav_module --with-http_flv_module --with-http_mp4_module --with-http_gunzip_module --with-threads --with-file-aio --with-dtrace-probes --with-http_ssl_module
curl
用curl来验证,也显示支持v2
curl --http2 -I https://xxx/
HTTP/2 500
server: nginx
content-type: application/octet-stream
content-length: 11
需要看看curl是否支持http2,显示也支持
curl -V
curl 7.55.1 (x86_64-pc-linux-gnu) libcurl/7.55.1 OpenSSL/1.0.1 zlib/1.2.3.4 nghttp2/1.26.0-DEV librtmp/2.3
Protocols: dict file ftp ftps gopher http https imap imaps ldap ldaps pop3 pop3s rtmp rtsp smb smbs smtp smtps telnet tftp
Features: AsynchDNS IPv6 Largefile NTLM NTLM_WB SSL libz TLS-SRP HTTP2 UnixSockets HTTPS-proxy
nginx源码
nginx源码中,没有搜索到这个字符串http v2 not supported yet
Openresty编译https
怀疑是Openresty没有编译进去http2,于是重新编译
./configure --prefix=/usr/local/openresty_http_v2
--with-pcre-jit
--with-ipv6
--with-http_iconv_module
--with-luajit
--with-http_v2_module
--with-openssl=/home/xxx/openssl-1.0.2l
-j2
--with-http_postgres_module --------------> 这个不行
但是这个版本也不行,同样的错误。
0x03 resty.upload代码排查
上传图片使用resty.upload
local UPLOAD = require "resty.upload"
local form,err = UPLOAD:new(chunk_size)
local typ, res, err = form:read()
所以我们去resty.upload代码看,发现使用了ngx.req.socket
local req_socket = ngx.req.socket
local sock, err = req_socket()
if not sock then
return nil, err
end
0x04 OpenResty源码
下载openresty源码,在ngx_http_lua_req_socket函数中,确实有这个字符串
static int ngx_http_lua_req_socket(lua_State *L) {
#if (NGX_HTTP_V2)
if (r->stream) {
return luaL_error(L, "http v2 not supported yet");
}
#endif
}
这明明是:在http v2情况下,socket不支持stream好不好!
0x05 解决
nginx.conf中,取消了http2的配置。这样客户端就知道后台只支持httpv1.1,就按照1.1来传输,就可以了。
- 冒泡排序简单操作模版及实例分析
- COGS 1299. bplusa【听说比a+b还要水的大水题???】
- python学习笔记之运算符
- 锐捷网络NBR部分路由器cookie欺骗权限绕过
- 手写快排模版
- COGS 68. [NOIP2005] 采药【01背包复习】
- UESTC 30 &&HDU 2544最短路【Floyd求解裸题】
- 我的第一个网页制作:Hello World!
- UESTC 1584 Washi与Sonochi的约定【树状数组裸题+排序】
- Hyperledger - 超级账本项目:简介,安装,案例
- 我的第三个网页制作:b、i、s、u、sub、sup标签的使用
- 【AlphaGo Zero 核心技术-深度强化学习教程代码实战04】Agent类和SARSA算法实现
- 我的第二个网页制作:p,hn,br标签的使用
- 超级账本项目:架构设计
- JavaScript 教程
- JavaScript 编辑工具
- JavaScript 与HTML
- JavaScript 与Java
- JavaScript 数据结构
- JavaScript 基本数据类型
- JavaScript 特殊数据类型
- JavaScript 运算符
- JavaScript typeof 运算符
- JavaScript 表达式
- JavaScript 类型转换
- JavaScript 基本语法
- JavaScript 注释
- Javascript 基本处理流程
- Javascript 选择结构
- Javascript if 语句
- Javascript if 语句的嵌套
- Javascript switch 语句
- Javascript 循环结构
- Javascript 循环结构实例
- Javascript 跳转语句
- Javascript 控制语句总结
- Javascript 函数介绍
- Javascript 函数的定义
- Javascript 函数调用
- Javascript 几种特殊的函数
- JavaScript 内置函数简介
- Javascript eval() 函数
- Javascript isFinite() 函数
- Javascript isNaN() 函数
- parseInt() 与 parseFloat()
- escape() 与 unescape()
- Javascript 字符串介绍
- Javascript length属性
- javascript 字符串函数
- Javascript 日期对象简介
- Javascript 日期对象用途
- Date 对象属性和方法
- Javascript 数组是什么
- Javascript 创建数组
- Javascript 数组赋值与取值
- Javascript 数组属性和方法
- leetcode树之二叉树的深度
- Nic*app的native层算法破解
- ActiveMq的顺序性消费问题
- 佳能遭严重勒索软件攻击,10TB数据被窃取,大量服务宕机
- 进程线程剖析(二)-进程组成、状态与特点
- 【Flink】基于 Flink 实时计算商品订单流失量
- 这就是你日日夜夜想要的docker!!!---------TLS加密远程连接Docker
- 【Flink】基于 Flink 的流式数据实时去重
- 从零开始安装穿透式检索
- 使用kind搭建kubernetes
- 如何设计一个牛逼的API接口
- 猿实战17——实现你未必知晓的运费模板
- 这 5 个 VSCode 扩展提高你的开发效率
- 猿实战18——商品发布之类目选择
- 树莓派基础实验1:双色LED灯实验