Skip to content

[KYUUBI #7807][TRINO] Take the session client address from the proxy client ip header - #7808

Open
Chaho12 wants to merge 1 commit into
apache:masterfrom
Chaho12:kyuubi-7807-trino-client-ip-header
Open

Chaho12 wants to merge 1 commit into
apache:masterfrom
Chaho12:kyuubi-7807-trino-client-ip-header

Conversation

@Chaho12

@Chaho12 Chaho12 commented Oct 28, 2026

Copy link
Copy Markdown
Contributor

Why are the changes needed?

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 and fall back to the TCP peer. The Trino frontend
always uses httpRequest.getRemoteAddr, so behind a load balancer or gateway every Trino session
gets the proxy's address. kyuubi.server.limit.connections.per.ipaddress then counts all Trino
clients against one address, kyuubi.server.limit.connections.ip.deny.list cannot single out a
client, and the session's clientIp shows the proxy.

This patch adds clientIpAddress to the Trino ApiRequestContext - the configured header if
present, otherwise the TCP peer - and uses it in the five places of StatementResource that build
a TrinoContext. The Trino frontend has no AuthenticationFilter, which is where the other HTTP
frontends read the header, so it reads the header itself.

One difference from REST: a blank header falls back to the TCP peer instead of becoming an empty
address, since the limiter and the ip deny list skip a blank address. As with the other frontends,
the header is trusted only as far as the proxy in front of the server.

Affects master and 1.11.1.

close #7807

How was this patch tested?

Added three cases to StatementResourceSuite, each submitting select 1 and checking the IP
address of the session it opens: with X-Real-IP: 10.1.2.3 it is 10.1.2.3; without the header,
and with a blank one, it is the TCP peer.

build/mvn test -pl kyuubi-server -am -Dtest=none \
    -DwildcardSuites=org.apache.kyuubi.server.trino.api.v1.StatementResourceSuite

All 7 pass with the change. With StatementResource reverted to getRemoteAddr, the header case
fails with "127.0.0.1" did not equal "10.1.2.3"; without the blank-header fallback, the blank
case fails with "" was empty.

The suite launches a Spark engine, so externals/kyuubi-spark-sql-engine has to be packaged first.

Was this patch assisted by generative AI tooling?

Assisted-by: Claude Opus 5.5

@Chaho12

Chaho12 commented Oct 28, 2026

Copy link
Copy Markdown
Contributor Author

cc @cxzl25 @wForget, could you take a look when you have time? Thanks!

@Chaho12
Chaho12 force-pushed the kyuubi-7807-trino-client-ip-header branch from 60b657d to fd2b64e Compare November 28, 2026 14:17

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] Trino frontend ignores kyuubi.frontend.proxy.http.client.ip.header and records the proxy as the client address

1 participant