我想知道是否有某种方法可以在 API Man 的请求标头上添加客户端远程 IP。
我需要添加一个简单的标头策略,其中包含一个包含客户端远程 ip 的“X-Forwarded-For”。
我的后端正在获取 APIMan IP 作为远程客户端,但我需要获取客户端 IP。
我想知道是否有某种方法可以在 API Man 的请求标头上添加客户端远程 IP。
我需要添加一个简单的标头策略,其中包含一个包含客户端远程 ip 的“X-Forwarded-For”。
我的后端正在获取 APIMan IP 作为远程客户端,但我需要获取客户端 IP。
You can create a custom policy plugin and override doApply
method to set the Client IP from ApiRequest
object to the custom header like below.
apiRequest.getHeaders().put("X-Forwarded-For", apiRequest.getRemoteAddr());
And add the new custom policy plugin to your services. This is a simple tutorial to create plugin