I am using Spring Cloud Gateway and CoreDNS in a Kubernetes cluster. Therefore, when making calls between pods within the cluster, I use addresses in the format http://..svc.cluster.local.

In this setup, when the client calls AWS load balancer > pod1 > pod2, I want to retrieve pod1's IP address, but I am getting the client IP instead. How can I fix this?

public Mono<Void> filter(ServerWebExchange exchange, GatewayFilterChain chain) {

        String remoteHostIp = exchange.getRequest().getRemoteAddress().getAddress()
            .getHostAddress();

        log.info("filter, remoteHostAddress: {}", remoteHostIp);

      .....
}

Comment From: bclozel

Thanks for getting in touch, but it feels like this is a question that would be better suited to Stack Overflow. As mentioned in the guidelines for contributing, we prefer to use the issue tracker only for bugs and enhancements. Feel free to update this issue with a link to the re-posted question (so that other people can find it) or add some more details if you feel this is a genuine bug.