Dockerized SpringBoot oAuth2 with Spring Cloud Gateway

  docker, oauth, spring, spring-boot

I have a little project with 3 micro-services on of those service is the security one that implements Spring Security with OAuth2 everything behind a simple Spring Cloud Gateway

public RouteLocator myRoutes (
        RouteLocatorBuilder builder
) {
    return builder.routes()
            .route(p -> p.path("/auth/**")
                    .filters(f -> f.rewritePath("^/auth", ""))
            .route(p -> p
                    .filters(f -> f.rewritePath("^/payments", ""))
            .route(p -> p
                    .filters(f -> f.rewritePath("^/insurance", ""))

Everything works, my Javascript client calls the auth server that shows up a login page and redirect back with the accessToken.

Now, when i try to Dockerize all of this i have issues with Spring oauth/authorize redirect. Infact it used the container hostname… and not the gateway path, so basically this happens

the last one in my mind should be

What i’m doing wrong? Is there a way to prevent it use the container hostname?

Source: Docker Questions