If the request is not forwarded by a proxy, you can obtain the client IP address from the requestContext.http.sourceIp field in the request struct.
If the request is forwarded by a proxy, you can obtain the client IP address from the X-Forwarded-For header in the request struct. If the request is forwarded by more than one proxy, the X-Forwarded-For header contains multiple IP addresses arranged in accordance with the forwarding sequence. In this case, the first IP address is the original client IP address.
Other HTTP request headers provide similar information, such as X-Real-IP and X-Client-IP.
ImportantExercise caution when you use X-Forwarded-For or another similar request header, such as X-Real-IP or X-Client-IP, to obtain client IP addresses because these headers may be forged.