nic-6443 opened a new pull request, #13499:
URL: https://github.com/apache/apisix/pull/13499

   ### Description
   
   Fixes #13498
   
   When `proxy-mirror` mirrors to a `grpc://` host, the mirrored request was 
sent with `:path = /proxy_mirror_grpc` (the internal mirror location name) 
instead of the real gRPC method path, so the mirror backend rejects every call 
with `UNIMPLEMENTED`. The cause is that `grpc_pass` cannot carry a URI (unlike 
the HTTP mirror location, which uses `proxy_pass $upstream_mirror_uri`), so the 
grpc module builds `:path` from the mirror subrequest's own URI.
   
   The fix captures the request path into a new `$upstream_mirror_grpc_path` 
variable and rewrites the mirror subrequest URI with it in the 
`proxy_mirror_grpc` location before `grpc_pass`. The capture happens in the 
`before_proxy` phase rather than rewrite, because access phase plugins (e.g. 
`grpc-web`) may rewrite the URI after `proxy-mirror`'s rewrite phase has run; 
`before_proxy` runs after all of them, so the mirrored `:path` always matches 
what the main upstream receives. `path` / `path_concat_mode` stay not 
applicable to gRPC mirroring, as already documented.
   
   The existing grpc mirror test from #9388 only asserted `Connection refused` 
against a closed port, so it could not catch this. It is reworked to mirror 
into a local h2c server that records the received request, asserting the 
`:path`, `content-type` and body length of the mirrored request; a second case 
covers the combination with `grpc-web`. Both fail before this fix (the mirror 
target receives `path=/proxy_mirror_grpc`) and pass after.
   
   ### 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
   - [ ] I have updated the documentation to reflect this change
   - [x] I have verified that this change is backward compatible
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to