apisix icon indicating copy to clipboard operation
apisix copied to clipboard

fix(forward-auth): client body can not send to upstream after forwarding it to auth. service

Open zhoujiexiong opened this issue 8 months ago • 5 comments

fix(forward-auth): client body can not send to upstream after forwarding it to auth. service

Description

Fixes https://github.com/apache/apisix/issues/11050 Fixes https://github.com/apache/apisix/issues/11200

  1. sync. with Nginx using ngx.req.<init|append|finish>_body APIs while forwarding/streaming to auth. svc
  2. consider the case of conf.allow_degradation == true
  3. delay invoking "get_client_body_reader() -> ngx.req.socket()"
  -- once invoking ngx.req.socket() would stop NGX from reading client body causing 504 issue
  -- why there is such a performance needs further clarification
  -- delay the invoking in order to follow the normal proxy_pass flow rather than buffering
  -- the client body by the plugin in case of client body has not started to read,
  -- e.g. auth svc. is unable to connect and allow_degradation is true
  1. suggest adding the following config field

-- suggest adding this switch forward_client_body = {type = "boolean", default = true},

Checklist

  • [x] I have explained the need for this PR and the problem it solves
  • [x] I have explained the changes or the new features added to this PR
  • [x] I have added tests corresponding to this change
  • [x] I have updated the documentation to reflect this change
  • [x] I have verified that this change is backward compatible (If not, please discuss on the APISIX mailing list first)

zhoujiexiong avatar Jun 12 '24 14:06 zhoujiexiong