Skip to content

Spring Cloud Gateway Webflux: I want to get the connection remote address #32976

@eunsujeo

Description

@eunsujeo

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);

      .....
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    for: stackoverflowA question that's better suited to stackoverflow.comstatus: invalidAn issue that we don't feel is valid

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions