I implement rate limiting in Spring Cloud Gateway (SCG). I get client IP address with below code
@Component
public class RemoteAddressKeyResolver implements KeyResolver {
@Override
public Mono<String> resolve(ServerWebExchange exchange) {
return Mono.just(exchange.getRequest().getRemoteAddress().getAddress().getHostAddress());
}
}
My SCG is behind a proxy so it gets address of proxy not real client address. How can I get real client address?