1

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.

4
  • Are there services registered with a secure port in eureka? Commented Aug 18, 2018 at 23:16
  • 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. Commented Aug 19, 2018 at 6:25
  • Can you show the output of <eurekaserver>/eureka/apps? Commented Aug 20, 2018 at 15:08
  • 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). Commented Aug 26, 2018 at 7:32

1 Answer 1

2

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.

Sign up to request clarification or add additional context in comments.

2 Comments

Hi @Konrad , I am facing the same issue. Could you tell me in which service did you set eureka.instance.securePort to 443 ? Gateway service or the other microservices ?
Hey @jackfr0st. Have a look into my commit history. I've set all the securePorts to 443. github.com/konraifen88-home/home-monitor-aio/commit/…

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.