kakawait / uaa-behind-zuul-sample

Spring AuthorizationServer load balanced behind Zuul
322 stars 156 forks source link

hostname different to localhost #2

Closed rmcruzv closed 7 years ago

rmcruzv commented 8 years ago

Hi friend,

I have been using your solution and I would like to say that works perfect while it's tested over localhost. But if I move the uaa-server and the gateway-server to a different host, the /uaa/oauth/authorize changes the "location" header to "uaa-host:gateway-port/uaa/login"

Ej: eureka-server: 192.168.0.10:8761 gateway-server: 192.168.0.11:8080 uaa-server: 192.168.0.12:9999

When gateway redirects to 192.168.0.11:8080/uaa/oauth/authorize, the "location" header of this response is change to: 192.168.0.12:8080/login

Could you tell me what I'm doing wrong?

kakawait commented 8 years ago

Hi @rmcruzv

To be honest I never tried outside localhost scope! So it may have a bug.

Could you please share with me your configuration files (properties or yml)?

I will check that after the weekend.


And if possible a HAR file or something that I can use to analyze request/response flow

rmcruzv commented 8 years ago

Finally I found a solution thanks to khuser. Basically that he does is create a ZuulFilter that overrides de "location" header changing the uaa-host by the proxy host

You can view the solution at:

https://github.com/spring-guides/tut-spring-security-and-angular-js/issues/43#issuecomment-167977246

My zuul config (I'm using SSL):

security:
  oauth2:
    client:
      accessTokenUri: https://localhost:${server.port}/sso/oauth/token
      userAuthorizationUri: /sso/oauth/authorize
...
eureka:
  client:
    serviceUrl:
      defaultZone: http://192.168.0.9:8761/eureka/
  instance:
    preferIpAddress: false
    hostname: 192.168.0.12
    securePortEnabled: true
    securePort: ${server.port}

My uaa-config

eureka:
  client:
    serviceUrl:
      defaultZone: http://192.168.0.9:8761/eureka/
  instance:
    preferIpAddress: true
    hostname: 192.168.0.10

Thanks for the quick answer

kakawait commented 8 years ago

Ok thank you for feedback, I think your solution is quite same as the following workaround: https://github.com/spring-cloud/spring-cloud-netflix/issues/942#issuecomment-209784604

I think I will try to create a docker setup with multi-domain (plus upgrade to Brixton.RELEASE) to improve POC

kakawait commented 7 years ago

@rmcruzv I'm using this implementation (a bit reworked for my special needs) on docker env, so each services have diff IP and I didn't reproduce any special issue.

Do you tried with latest version?