How to obtain the real application server IP instead of the HAProxy server IP when logging into TiDB using HAProxy

Note:
This topic has been translated from a Chinese forum by GPT and might contain errors.

Original topic: 使用haproxy登陆tidb,怎么能获取真正的应用服务器ip,而不是haproxy服务器的ip

| username: TiDBer_BrIoQ0NO

[TiDB Usage Environment] Production\Test Environment\POC
[TiDB Version] V5.4
[Encountered Problem]
Three TiDB components: 192.168.10.2, 192.168.10.3, 192.168.10.4
HAProxy: 192.168.10.5
Application Server: 192.168.10.6
A HAProxy is set up on top of the three TiDB components. When logging into TiDB through HAProxy and executing select instance, id, user, host, db from INFORMATION_SCHEMA.cluster_processlist WHERE command != 'Sleep';, it is found that the host value corresponding to all SQL executed by the application server is the IP of the HAProxy machine (192.168.10.5) instead of the IP of the application server (192.168.10.6).
[Reproduction Path] None
[Problem Phenomenon and Impact] None

| username: OnTheRoad | Original post link

Isn’t this normal?

| username: CuteRay | Original post link

You can refer to this article to learn about IP passthrough
Column - TiDB + HAProxy Configuration for IP Passthrough | TiDB Community