openresty / openresty/lua-nginx-module
Problem with HTTPS and internal request
Nobody has claimed this yet.
- Dominant language
- C
- Stars
- 11.8k
- Forks
- 2.1k
- Avg merge
- 6h 1m
- Merged PRs (30d)
- 6
Description
I'm using Lua to detect request type and forward to one PHP server or another, but if I enable SSL, I'm getting an error (000 response).
Here is what I'm doing:
api.conf
location /check-session {
content_by_lua_file check-session.lua;
}
check-session.lua
JSON = (loadfile "/usr/local/openresty/lualib/conf/utils/JSON.lua")()
local reqType = ngx.var.request_method
ngx.req.read_body()
if reqType == "POST" then
local body = ngx.req.get_body_data()
local decoded_body = JSON:decode(body)
decoded_body ["meta"] = {
//add some stuff
}
local modified_body = JSON:encode (decoded_body)
local response = ngx.location.capture("/php",
{
body = modified_body,
copy_all_vars = true
}
)
for headerName, header in pairs(response.header) do
ngx.header[headerName] = header
end
ngx.status = response.status
ngx.say(response.body)
ngx.exit(response.status)
php.conf
location /php {
internal;
root /api;
fastcgi_param SCRIPT_FILENAME $document_root/ajax.php;
fastcgi_param REQUEST_METHOD $request_method;
fastcgi_param PATH_INFO $fastcgi_path_info;
fastcgi_index ajax.php;
fastcgi_pass php:9000;
include fastcgi_params;
}
This worked fine until I started using SSL, Now I got a 000 response in logx and client will never see a response, just keeps loading.
Using openresty/1.11.2.1
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 by reviewing api.conf, check-session.lua, and php.conf, then reproduce the internal ngx.location.capture request with SSL enabled and compare it with the working non-SSL setup. Trace where the 000 response is produced and establish a response that reaches the client without hanging; the issue does not identify a failing test or expected fix.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- lua, nginx, php
- Domain
- backend, networking
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100