ledgetech / lua-resty-http

Lua HTTP client cosocket driver for OpenResty / ngx_lua.
BSD 2-Clause "Simplified" License
1.97k stars 621 forks source link

tengine2.3.4+tongsuo 8.4+lua-nginx-module+LuaJIT 2.1.1710398010 #315

Open liujhjack opened 2 months ago

liujhjack commented 2 months ago

luajit -v
LuaJIT 2.1.1710398010 -- Copyright (C) 2005-2023 Mike Pall. https://luajit.org/

nignx -V configure arguments: --prefix=/usr/local/nginx --sbin-path=/usr/local/nginx/sbin/nginx --with-http_lua_module --with-threads --with-file-aio --with-select_module --with-poll_module --with-http_ssl_module --with-http_stub_status_module --with-http_degradation_module --with-http_sub_module --with-stream --with-stream_ssl_module --with-stream_sni --with-stream_ssl_preread_module --with-openssl=/opt/compile/depend/Tongsuo--with-openssl-opt='--api=1.1.1 enable-ntls' --add-module=modules/ngx_openssl_ntls --add-module=/opt/compile/depend/headers-more-nginx-module-0.33

nginx.conf

lua_package_path '/opt/luarocks/share/lua/5.1/?.lua;;'; lua_package_cpath '/opt/luarocks/lib/lua/5.1/?.so;;';

location ^~ /lua { content_by_lua_block { local json = require("cjson") local http = require("resty.http")

local uri = "https://www.baidu.com"

ngx.log(ngx.ERR, "request url: " .. uri) ngx.say("request to ", uri)

local httpc = http.new() local res, err = httpc:request_uri(uri, { method = "GET", })

if not res then ngx.say("Failed to post request to ", uri, ": ", err) return end

ngx.say("Status: ", res.status) ngx.say("Body: ", res.body)

            }

}

error.log

2024/05/10 18:12:29 [info] 4698#4698: 39 SSL_do_handshake() failed (SSL: error:0A000416:SSL routines::sslv3 alert certificate unknown:SSL alert number 46) while SSL handshaking, client: 10.11.47.29, server: 0.0.0.0:443 2024/05/10 18:12:29 [info] 4698#4698: 40 SSL_do_handshake() failed (SSL: error:0A000416:SSL routines::sslv3 alert certificate unknown:SSL alert number 46) while SSL handshaking, client: 10.11.47.29, server: 0.0.0.0:443 2024/05/10 18:12:29 [warn] 4698#4698: 41 [lua] http_connect.lua:21: failed to load module `resty.openssl.`, mTLS isn't supported without lua-resty-openssl: /opt/luarocks/share/lua/5.1/resty/http_connect.lua:15: module 'resty.openssl.x509.chain' not found: no field package.preload['resty.openssl.x509.chain'] no file '/opt/luarocks/share/lua/5.1/resty/openssl/x509/chain.lua' no file './resty/openssl/x509/chain.lua' no file '/usr/local/share/luajit-2.1/resty/openssl/x509/chain.lua' no file '/usr/local/share/lua/5.1/resty/openssl/x509/chain.lua' no file '/usr/local/share/lua/5.1/resty/openssl/x509/chain/init.lua' no file '/opt/luarocks/lib/lua/5.1/resty/openssl/x509/chain.so' no file './resty/openssl/x509/chain.so' no file '/usr/local/lib/lua/5.1/resty/openssl/x509/chain.so' no file '/usr/local/lib/lua/5.1/loadall.so' no file '/opt/luarocks/lib/lua/5.1/resty.so' no file './resty.so' no file '/usr/local/lib/lua/5.1/resty.so' no file '/usr/local/lib/lua/5.1/loadall.so' stack traceback: [C]: in function 'require' /opt/luarocks/share/lua/5.1/resty/http_connect.lua:15: in function </opt/luarocks/share/lua/5.1/resty/http_connect.lua:14> [C]: in function 'xpcall' /opt/luarocks/share/lua/5.1/resty/http_connect.lua:14: in main chunk [C]: in function 'require' /opt/luarocks/share/lua/5.1/resty/http.lua:166: in main chunk [C]: in function 'require' content_by_lua(login.conf:76):5: in main chunk, client: 10.11.47.29, server: , request: "GET /lua HTTP/1.1", host: "10.50.89.231" 2024/05/10 18:12:29 [error] 4698#4698: 41 [lua] content_by_lua(login.conf:76):13: request url: https://www.baidu.com, client: 10.11.47.29, server: , request: "GET /lua HTTP/1.1", host: "10.50.89.231" 2024/05/10 18:12:29 [debug] 4698#4698: 41 [lua] http_connect.lua:253: connect(): poolname: https:www.baidu.com:443:true:www.baidu.com:false::: 2024/05/10 18:12:29 [notice] 13827#13827: signal 17 (SIGCHLD) received from 4698 2024/05/10 18:12:29 [alert] 13827#13827: worker process 4698 exited on signal 11

Does the lua-resty-http library have compatibility issues with the TongSuo SSL library?

liujhjack commented 2 months ago

luarocks install lua-resty-openssl

luarocks list

Rocks installed for Lua 5.1

lua-cjson 2.1.0.10-1 (installed) - /opt/luarocks/lib/luarocks/rocks-5.1

lua-resty-http 0.17.2-0 (installed) - /opt/luarocks/lib/luarocks/rocks-5.1

lua-resty-openssl 1.3.1-1 (installed) - /opt/luarocks/lib/luarocks/rocks-5.1

lua-resty-string 0.09-0 (installed) - /opt/luarocks/lib/luarocks/rocks-5.1

################error.log######################## 2024/05/10 18:30:23 [info] 14885#14885: 65 SSL_do_handshake() failed (SSL: error:0A000416:SSL routines::sslv3 alert certificate unknown:SSL alert number 46) while SSL handshaking, client: 10.11.47.29, server: 0.0.0.0:443 2024/05/10 18:30:23 [info] 14885#14885: 66 SSL_do_handshake() failed (SSL: error:0A000416:SSL routines::sslv3 alert certificate unknown:SSL alert number 46) while SSL handshaking, client: 10.11.47.29, server: 0.0.0.0:443 2024/05/10 18:30:23 [warn] 14885#14885: 67 [lua] http_connect.lua:21: failed to load module `resty.openssl.`, mTLS isn't supported without lua-resty-openssl: ...uarocks/share/lua/5.1/resty/openssl/auxiliary/compat.lua:32: module 'ngx.base64' not found: no field package.preload['ngx.base64'] no file '/opt/luarocks/share/lua/5.1/ngx/base64.lua' no file '/opt/luarocks/share/lua/5.1/ngx/base64/init.lua' no file './ngx/base64.lua' no file '/usr/local/share/luajit-2.1/ngx/base64.lua' no file '/usr/local/share/lua/5.1/ngx/base64.lua' no file '/usr/local/share/lua/5.1/ngx/base64/init.lua' no file '/opt/luarocks/lib/lua/5.1/ngx/base64.so' no file './ngx/base64.so' no file '/usr/local/lib/lua/5.1/ngx/base64.so' no file '/usr/local/lib/lua/5.1/loadall.so' no file '/opt/luarocks/lib/lua/5.1/ngx.so' no file './ngx.so' no file '/usr/local/lib/lua/5.1/ngx.so' no file '/usr/local/lib/lua/5.1/loadall.so' stack traceback: [C]: in function 'require' ...uarocks/share/lua/5.1/resty/openssl/auxiliary/compat.lua:32: in main chunk [C]: in function 'require' /opt/luarocks/share/lua/5.1/resty/openssl/version.lua:5: in main chunk [C]: in function 'require' /opt/luarocks/share/lua/5.1/resty/openssl/include/err.lua:4: in main chunk [C]: in function 'require' /opt/luarocks/share/lua/5.1/resty/openssl/err.lua:7: in main chunk [C]: in function 'require' /opt/luarocks/share/lua/5.1/resty/openssl/stack.lua:14: in main chunk [C]: in function 'require' /opt/luarocks/share/lua/5.1/resty/openssl/x509/chain.lua:5: in main chunk [C]: in function 'require' /opt/luarocks/share/lua/5.1/resty/http_connect.lua:15: in function </opt/luarocks/share/lua/5.1/resty/http_connect.lua:14> [C]: in function 'xpcall' /opt/luarocks/share/lua/5.1/resty/http_connect.lua:14: in main chunk [C]: in function 'require' /opt/luarocks/share/lua/5.1/resty/http.lua:166: in main chunk [C]: in function 'require' content_by_lua(login.conf:77):5: in main chunk, client: 10.11.47.29, server: , request: "GET /lua HTTP/1.1", host: "10.50.89.231" 2024/05/10 18:30:23 [error] 14885#14885: 67 [lua] content_by_lua(login.conf:77):13: request url: https://www.baidu.com, client: 10.11.47.29, server: , request: "GET /lua HTTP/1.1", host: "10.50.89.231" 2024/05/10 18:30:23 [debug] 14885#14885: 67 [lua] http_connect.lua:253: connect(): poolname: https:www.baidu.com:443:true:www.baidu.com:false::: 2024/05/10 18:30:23 [notice] 13827#13827: signal 17 (SIGCHLD) received from 14885 2024/05/10 18:30:23 [alert] 13827#13827: worker process 14885 exited on signal 11