Chaho12 opened a new issue, #7807: URL: https://github.com/apache/kyuubi/issues/7807
### Code of Conduct - [x] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct) ### Search before asking - [x] I have searched in the [issues](https://github.com/apache/kyuubi/issues?q=is%3Aissue) and found no similar issues. ### Describe the bug The thrift HTTP and REST frontends take the client address of a session from the header named by `kyuubi.frontend.proxy.http.client.ip.header` (default `X-Real-IP`) and fall back to the TCP peer (`KyuubiTHttpFrontendService.getIpAddress`, `KyuubiRestFrontendService.getIpAddress`). The Trino frontend does not: `StatementResource` passes `httpRequest.getRemoteAddr` to `TrinoContext` in all five places, and that becomes the session's IP address in `Query.getOrCreateSession`. So behind a load balancer or gateway, every Trino session gets the proxy's address. Everything that works per client address then sees one client: - `kyuubi.server.limit.connections.per.ipaddress` counts all Trino clients against one address, so it either has to be turned off or turns everyone away at once - `kyuubi.server.limit.connections.ip.deny.list` cannot single out a client - the session's `clientIp` in the REST API and session events, and its address in the logs, show the proxy Steps to reproduce: 1. Put a proxy in front of the Trino frontend that sets `X-Real-IP` to the client address, or send the header directly: `curl -H 'X-Real-IP: 10.1.2.3' -H 'X-Trino-User: alice' -d 'select 1' http://<kyuubi>:<trino-port>/v1/statement` 2. Look the session up with `GET /api/v1/sessions/<sessionHandle>` - its `clientIp` is the TCP peer, not `10.1.2.3`. ### Affects Version(s) master/1.11.1 ### Kyuubi Server Log Output ```logtalk > No error is logged: the session is opened with the proxy's address. ``` ### Kyuubi Engine Log Output ```logtalk > Not related to the engine ``` ### Kyuubi Server Configurations ```yaml kyuubi.frontend.protocols TRINO kyuubi.frontend.proxy.http.client.ip.header X-Real-IP ``` ### Kyuubi Engine Configurations ```yaml > Not related to the engine ``` ### Additional context Fix proposal: resolve the client address in the Trino `ApiRequestContext` the same way the other HTTP frontends do - the configured header if present, otherwise the TCP peer - and use it in `StatementResource`. As with thrift HTTP and REST, the header is trusted only as far as the proxy in front of the server. ### Are you willing to submit PR? - [x] Yes. I would be willing to submit a PR with guidance from the Kyuubi community to fix. - [ ] No. I cannot submit a PR at this time. -- 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] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
