1
votes

I've been trying to get my apps to run after deploing them to a CloudFoundry instance. The instance I'm using will not allow to perform requests using http (they will simply timeout) so I have to route all requests to https.

The components/versions I am using are:

  • Java 10
  • Spring Boot 2.0.4.RELEASE/Spring Cloud Finchley.SR1
  • spring-cloud-gateway
  • spring-cloud-config-server
  • spring-cloud-starter-netflix-eureka

The failing config

EurekaClient Config (in gateway and the backend where the gw should route to)

eureka:
  client:
    serviceUrl:
      defaultZone: ${DISCOVERY_SERVICE_URL:http://localhost:8061}/eureka/
  instance:
    hostname: ${vcap.application.uris[0]:localhost}
    nonSecurePortEnabled: false
    securePortEnabled: true
    securePort: ${server.port}
    statusPageUrl: https://${eureka.instance.hostname}/actuator/info
    healthCheckUrl: https://${eureka.instance.hostname}/actuator/health
    homePageUrl: https://${eureka.instance.hostname}/
    secure-virtual-host-name: https://${vcap.application.application_uris[0]}

Gateway Config

spring:
  cloud:
    gateway:
      discovery:
        locator:
          enabled: true
      routes:
      - id: user-service
        uri: lb://user-service
        predicates:
        - Path=/user/**
        filters:
        - RewritePath=/user/(?<segment>.*), /$\{segment}

Things I have already tried:

  • Using lb:https://user-service like described in docs -> Will have no effect as far as I can see
  • Use real urls to the apps (uri: https://user-service.cf-instance.io) -> Routing works as expected.

But I do not want to define the urls in my config, they should returned by eureka and build up correctly by the gateway.

Thanks in advance

Edit:

Here is the output of /eureka/apps https://pastebin.com/WP3b6PQG

I am currently working to get the current code into GitHub I will edit this post when I've found the time to get a clear state.

Edit 2:

You can find the full example (With SpringCloudGateway, Eureka, ...) at my GitHub This is an running example, the applied config will not use the Eureka. To use Eureka the gateway-service-cloud.yml in config service has to be adopted.

- id: user-service uri: lb://user-service

Please ignore the documentation service, this will not work yet, I first need to rewrite the path.

1
Are there services registered with a secure port in eureka? - spencergibb
Yes, the services are properly registered in the eureka dashboard. When I click the ID in the dashboard I am redirected to the health endpoint of the service. Also the response to the gateway contains the correct uri, but without the schema itself. So I think that there is something missing in the Gateway Config that the schema can/will be set to https. - Konrad Grüner
Can you show the output of <eurekaserver>/eureka/apps? - spencergibb
I've edited the post to add the information you asked for. Today I did another test. I deployed the apps with 2 different configurations. The first one was with fix https urls and the other with lb config. The generated xml for /eureka/apps is exactly the same (except ip, timestamps and id). - Konrad Grüner

1 Answers

1
votes

Ok, I found out the solution during fixing the "routing" problem with my documentation-service.

My problem was setting the property eureka.instance.securePort to ${server.port}. This property has to be set to 443 (the default 443 is not applied when nothing is set). When adding this to my configurations everything works as expected after pushing my application.