openresty / openresty/lua-nginx-module
ngx.location.capture + proxy_pass == stuck, no response
Nobody has claimed this yet.
- Dominant language
- C
- Stars
- 11.8k
- Forks
- 2.1k
- Avg merge
- 6h 1m
- Merged PRs (30d)
- 6
Description
I have two locations like this:
location ~* ^/proxy_test/(.*?)/(.*) {
proxy_pass_request_headers off;
proxy_pass http://$1/$2;
}
location ~* ^/test/(.*?)/(.*) {
set $a $1;
set $b $2;
content_by_lua '
local url = "/proxy_test/" .. ngx.var.a .. "/" .. ngx.var.b
res = ngx.location.capture(url)
ngx.say(res.status)
';
}
Then I make a request to test/static.adit.io/guitar.jpg. This should:
- make a subrequest to
/proxy_test/static.adit.io/guitar.jpg, which will download the image and serve it - the response gets saved to
res - the status gets printed out.
However, this request never finishes. Turning debugging on, here's what I see:
The subrequest gets made:
2014/08/22 23:56:33 [debug] 36366#0: *4 http proxy header:
"GET /guitar.jpg HTTP/1.0
Host: static.adit.io
Connection: close
A response is received:
2014/08/22 23:56:33 [debug] 36366#0: *4 recv: fd:39 214 of 4096
2014/08/22 23:56:33 [debug] 36366#0: *4 http proxy status 200 "200 OK"
2014/08/22 23:56:33 [debug] 36366#0: *4 http proxy header: "Server: nginx/1.2.3"
2014/08/22 23:56:33 [debug] 36366#0: *4 http proxy header: "Date: Fri, 22 Aug 2014 23:56:33 GMT"
2014/08/22 23:56:33 [debug] 36366#0: *4 http proxy header: "Content-Type: image/jpeg"
2014/08/22 23:56:33 [debug] 36366#0: *4 http proxy header: "Content-Length: 641458"
2014/08/22 23:56:33 [debug] 36366#0: *4 http proxy header: "Last-Modified: Wed, 02 Jul 2014 04:30:27 GMT"
2014/08/22 23:56:33 [debug] 36366#0: *4 http proxy header: "Connection: close"
2014/08/22 23:56:33 [debug] 36366#0: *4 http proxy header: "Accept-Ranges: bytes"
2014/08/22 23:56:33 [debug] 36366#0: *4 http proxy header done
Then I see plenty of this (not sure what to make of it). The last lines in the log are:
2014/08/22 23:56:34 [debug] 36366#0: *4 pipe buf in s:1 t:1 f:0 00000000019132C0, pos 00000000019132C0, size: 32768 file: 0, size: 0
2014/08/22 23:56:34 [debug] 36366#0: *4 pipe length: 375432
But there has been no response from the server. My request just hangs for minutes until I finally kill it.
Lua version: LuaJIT 2.0.3 -- Copyright (C) 2005-2014 Mike Pall. http://luajit.org/
Nginx version: nginx/1.2.9
CentOS release 6.5 x86_64
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the two location blocks and reproduce the request to /test/static.adit.io/guitar.jpg using the provided nginx debug output. Trace the ngx.location.capture subrequest through proxy_pass and the response body handling. Done means determining why the request does not finish after the upstream response and documenting or fixing that behavior with a reproducible test.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- lua, nginx
- Domain
- backend
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100