lua-nginx-module
lua-nginx-module copied to clipboard
HTTP/2 with location.capture() re-enable
I have tried to reproduce https://github.com/openresty/lua-nginx-module/issues/1195#issue-275974888 mentioned bug by revert https://github.com/openresty/lua-nginx-module/commit/3078ca6138121a98e22104b9f7015b31d312861b commit
user root;
worker_rlimit_core 500M;
events {
worker_connections 1024;
}
http {
log_format compression '$remote_addr - $remote_user [$time_local] '
'"$request" $status $bytes_sent '
'"$http_referer" "$http_user_agent" "$gzip_ratio"';
access_log logs/access.log compression;
proxy_cache_path /tmp/nginx/cache keys_zone=api_key:10m;
server {
listen 8080 http2;
location /main2 {
content_by_lua '
local res2 = ngx.location.capture("/internal/api", {
method = ngx.HTTP_POST,
body = body,
args = {hello = "world"}
})
ngx.say(res2.body)
';
}
location /foo {
echo -n world;
}
location /bar {
echo -n ' people';
}
location = /internal/api {
internal;
proxy_method GET;
proxy_cache_methods GET HEAD POST;
proxy_cache_valid any 5m;
proxy_cache api_key;
proxy_cache_key api_$args;
proxy_pass https://httpbin.org/anything;
}
}
}
curl --http2-prior-knowledge 127.0.0.1:8080/main2/api\?a=1 -H "accept: application/json" -X POST -vv
* Trying 127.0.0.1:8080...
* Connected to 127.0.0.1 (127.0.0.1) port 8080
* [HTTP/2] [1] OPENED stream for http://127.0.0.1:8080/main2/api?a=1
* [HTTP/2] [1] [:method: POST]
* [HTTP/2] [1] [:scheme: http]
* [HTTP/2] [1] [:authority: 127.0.0.1:8080]
* [HTTP/2] [1] [:path: /main2/api?a=1]
* [HTTP/2] [1] [user-agent: curl/8.4.0]
* [HTTP/2] [1] [accept: application/json]
> POST /main2/api?a=1 HTTP/2
> Host: 127.0.0.1:8080
> User-Agent: curl/8.4.0
> accept: application/json
>
< HTTP/2 200
< server: openresty/1.21.4.2
< date: Thu, 19 Oct 2023 15:32:30 GMT
< content-type: text/plain
<
{
"args": {
"hello": "world"
},
"data": "",
"files": {},
"form": {},
"headers": {
"Accept": "application/json",
"Host": "httpbin.org",
"User-Agent": "curl/8.4.0",
"X-Amzn-Trace-Id": "Root=1-65314b87-0647d43721dc60d564c46b16"
},
"json": null,
"method": "GET",
"url": "https://httpbin.org/anything?hello=world"
}
curl --http2-prior-knowledge 127.0.0.1:8080/main2/api\?a=1 -H "accept: application/json" -X POST -vv
* Trying 127.0.0.1:8080...
* Connected to 127.0.0.1 (127.0.0.1) port 8080
* [HTTP/2] [1] OPENED stream for http://127.0.0.1:8080/main2/api?a=1
* [HTTP/2] [1] [:method: POST]
* [HTTP/2] [1] [:scheme: http]
* [HTTP/2] [1] [:authority: 127.0.0.1:8080]
* [HTTP/2] [1] [:path: /main2/api?a=1]
* [HTTP/2] [1] [user-agent: curl/8.4.0]
* [HTTP/2] [1] [accept: application/json]
> POST /main2/api?a=1 HTTP/2
> Host: 127.0.0.1:8080
> User-Agent: curl/8.4.0
> accept: application/json
>
< HTTP/2 200
< server: openresty/1.21.4.2
< date: Thu, 19 Oct 2023 15:36:08 GMT
< content-type: text/plain
<
{
"args": {
"hello": "world"
},
"data": "",
"files": {},
"form": {},
"headers": {
"Accept": "application/json",
"Host": "httpbin.org",
"User-Agent": "curl/8.4.0",
"X-Amzn-Trace-Id": "Root=1-65314ce8-504043c862ceaf6a48dbe6ce"
},
"json": null,
"method": "GET",
"url": "https://httpbin.org/anything?hello=world"
}
I can not reproduce this problem, Just wanted to know if it's possible to revert the https://github.com/openresty/lua-nginx-module/commit/3078ca6138121a98e22104b9f7015b31d312861b commit to enable HTTP2 location.capture() support.
If anyone can help me to reproduce this problem, I would be very willing to dig it up and fix it.