spring-cloud / spring-cloud-config

External configuration (server and client) for Spring Cloud
Apache License 2.0
1.95k stars 1.29k forks source link

Spring Cloud Config with Eureka - contextPath #1242

Closed leebake closed 5 years ago

leebake commented 5 years ago

I have a problem with discovery config-server via Eureka. My apps are deployed on WebLogic server with contextPath given in wls:context-root.

  1. Config server
contextRoot: /config-server

application.yml

server:
  port: 7001

context-path: config-server

eureka:
  instance:
    status-page-url-path: ${context-path}/info
    health-check-url-path: ${context-path}/health
  client:
    serviceUrl:
      defaultZone: http://localhost:7001/service-registry/eureka/
spring:
  application:
    name: configserver
  cloud:
    config:
      server:
        git:
          uri: URL TO REPO
  1. Eureka
    contextRoot: /service-registry

    bootstrap.yml

    server:
    port: 7001
    spring:
    cloud:
    config:
      name: discovery
      uri: http://localhost:7001/config-server/
  2. MS1
    contextRoot: /ms1

    bootstrap.yml

    spring:
    cloud:
    config:
      name: message-store
      discovery:
        enabled: true
      fail-fast: true
    eureka:
    client:
    serviceUrl:
      defaultZone: http://localhost:7001/service-registry/eureka/

The MS1 can't get config from config-server because it send a request to localhost:7001 - wthout contextPath. That's the address MS1 (I suppose) gets from Eureka. Why Eureka dont't return url with contextPath? Config server has been registered with both status-page-url-path and health-check-url-path contains contextPath.

ryanjbaxter commented 5 years ago

This is handled via the metadata provided to Eureka via the config server. See the documentation here http://cloud.spring.io/spring-cloud-static/Greenwich.RELEASE/single/spring-cloud.html#discovery-first-bootstrap

leebake commented 5 years ago

It works! Thank you @ryanjbaxter !