apache / apisix

The Cloud-Native API Gateway
https://apisix.apache.org/blog/
Apache License 2.0
14.58k stars 2.53k forks source link

bug: wrong request forwarded to the upstream server #11381

Open lilililizheng opened 5 months ago

lilililizheng commented 5 months ago

Current Behavior

When using a reverse proxy, if in the request URL with parameters, such as: https://192.168.0.253:9443/hello? t=32132432, there will be an error when forwarding upstream. I have captured and traced the packet here, and there should be a coding problem when forwarding upstream. The request result I caught is GET hello%3F=32132432&t=32132432.

This can not be seen in the apisix log, the whole request is completely normal, but the wrong request was forwarded to the upstream server, the server can not handle the error correctly, this problem I roughly traced, it seems that there is a problem with the request: function _M.set_current_peer(addr, port) local r = get_request() print(require("ffi").string(r)) if not r then error("no request found") end

if not port then
    port = 0
elseif type(port) ~= "number" then
    port = tonumber(port)
end

local rc = ngx_lua_ffi_balancer_set_current_peer(r, addr, #addr,
                                                 port, errmsg)
if rc == FFI_OK then
    return true
end

return nil, ffi_str(errmsg[0])

end

Expected Behavior

No response

Error Logs

No response

Steps to Reproduce

I'm just normal use reverse proxy aapisix doing, just be proxy site some request need take parameters, such as: https://192.168.254.211/initialization/check? t=1719806422715, so if I want to use apisix to proxy this service, it is not successful

Environment

lilililizheng commented 5 months ago

Looking forward to your handling and reply

shreemaan-abhishek commented 5 months ago

any error logs?

lilililizheng commented 5 months ago

There will not be any error logs, because the whole process of proxy forwarding is completely correct, only when the request is forwarded upstream, the request is changed, as I said above, I send the request upstream is /initialization/check? t=1719806422715. However, after Apisix forwards the request, it becomes /initialization/check%3Ft=1719806422715t=1719806422715. As a result, my server does not recognize the request and returns an error. I think reverse proxy is the basic function of this app and hope to fix the problem quickly