首页 > 解决方案 > Eureka + Zuul + Spring Cloud Config Server + HTTPS 问题

问题描述

我正在使用微服务架构开发应用程序。我正在使用 Spring Cloud Eureka 和 Spring Cloud Zuul。我也在使用 Cloud Config Server,因为我想动态地将路由添加到 Zuul 网关。我在使用 Cloud Config Server 时遇到问题。它在 Eureka Server 上注册(我在 Eureka Dashboard 中看到了它的一个实例),但是当我运行 Zuul Gateway 时,例如,我得到一个异常

“java.lang.IllegalStateException:找不到配置服务器(云配置服务器)的实例”

然后微服务关闭。问题开始于 HTTPS 协议实施后。在此之前,相同的微服务配置和配置服务器运行良好。

在此处输入图像描述

这是 Eureka application.yml 文件:

eureka:
  client:
    registerWithEureka: false
    fetchRegistry: false
  server:
    waitTimeInMsWhenSyncEmpty: 0
  instance:
    hostname: localhost
    securePort: ${server.port}
    securePortEnabled: true  
    nonSecurePortEnabled: false 
    homePageUrl: https://${eureka.instance.hostname}:${server.port}/
    statusPageUrl: https://${eureka.instance.hostname}:${server.port}/admin/info
server:
  port: 8761
  ssl:
    enabled: true
    key-alias: service-registry
    key-store: classpath:service-registry.jks
    key-store-password: password
    key-store-type: JKS
    trust-store: classpath:service-registry.jks
    trust-store-password: password
    trust-store-type: JKS

这是 Zuul application.yml 文件:

server:
  port: 8762
  ssl:
    enabled: true
    key-store: classpath:zuul-gateway.jks
    key-store-password: password
    key-alias: zuul-gateway
eureka:
  instance:
    hostname: localhost
    nonSecurePortEnabled: false
    securePortEnabled: true
    securePort: ${server.port}
    statusPageUrl: https://localhost:${server.port}/info
    healthCheckUrl: https://localhost:${server.port}/health
    homePageUrl: https://localhost:${server.port}
  client:
    serviceUrl:
      defaultZone:  ${EUREKA_URI:https://localhost:8761/eureka}
    fetch-registry: true
    register-with-eureka: true
zuul:
  prefix: /api
  routes:
    mock-bitcoin-service:
      service-id: mock-bitcoin-service
      path: /mock-bitcoin-service/**
  host:
    connect-timeout-millis: 5000000
    socket-timeout-millis: 5000000
  ignoredServices: '*'

hystrix:
  command:
    default:
      execution:
        isolation:
          thread:
            timeoutInMilliseconds: 12000
ribbon:
  ConnectTimeout: 10000
  ReadTimeout: 10000

这是 Spring Cloud Config Server application.yml 文件:

server:
  port: 8888
  ssl:
    enabled: true
    key-store: classpath:cloud-config-server.jks
    key-store-password: password
    key-alias: cloud-config-server
    key-store-type: JKS
    trust-store: classpath:cloud-config-server.jks
    trust-store-password: password
    trust-store-type: JKS
eureka:
  instance:
    nonSecurePortEnabled: false
    securePortEnabled: true
    securePort: ${server.port}
    statusPageUrl: https://localhost:${server.port}/info
    healthCheckUrl: https://localhost:${server.port}/health
    homePageUrl: https://localhost:${server.port}
    lease-expiration-duration-in-seconds: 20
    lease-renewal-interval-in-seconds: 10
  client:
    enabled: true
    instance-info-replication-interval-seconds: 10
    registry-fetch-interval-seconds: 10
    serviceUrl:
      defaultZone:  ${EUREKA_URI:https://localhost:8761/eureka}
    fetch-registry: true
    register-with-eureka: true
spring:
  cloud:
    config:
      server:
        git:
          clone-on-start: true
          search-paths: /config/{application}
          uri: https://github.com/XXXX.git

问题:有没有人遇到过这种问题,有谁知道我该如何解决?

标签: springhttpsnetflix-eurekanetflix-zuulspring-cloud-config

解决方案


推荐阅读