Closed
Description
Hi,
Got bitten by workers crashes in LUA due to ngx.location.capture requesting a location that has the ability to sendfile large files.
Found out that if subrequests makes use of the X-Accel-Redirect, the actual file content gets fully loaded within the subrequest, and then sent back to LUA at once, as a single large chunk of memory... and potentially blowing stuff in the LUA VM.
This is actually understandable, but a quick note in the doc might help as it's easy to overlook this!
My fix in my case is to:
- push a different sendfile header from the backend (ie, something different than X-Accel-Redirect) in order to prevent the ngx.location.capture subrequest from loading the file,
- test this header when returning from ngx.location.capture() and,
- if found, use return ngx.exec(header value) to exit from LUA and stream the file back to the client
Not sure if a better/nicer way exists though!
Cedric
Metadata
Metadata
Assignees
Labels
No labels