【问题标题】:Spring Cloud Sidecar is not working as expectedSpring Cloud Sidecar 未按预期工作
【发布时间】:2016-08-12 23:48:41
【问题描述】:

根据文档,@EnableSidecar 注释充当希望在 Eureka 中注册的非 JVM 应用程序的代理。因此,要设置的配置是:

sidecar:
  port: 81 <-- Port of the non-JVM application
  health-uri: http://10.135.16.50:${sidecar.port}/api/health.php <-- URI of the non-JVM application's health endpoint
  home-page-uri: http://10.135.16.50:${sidecar.port}/

一旦“sidecar”启动并运行,我们应该能够通过服务注册表调用非 JVM 端点之一,只需使用“sidecar”应用程序在 Eureka 中注册的名称。因此,例如,如果我们的“sidecar”应用程序在 Eureka 中注册为“php-sidecar”,以代理具有以下端点的 PHP 应用程序:

http://10.135.16.50:81/api/microservice.php

然后我们应该能够调用以下端点来访问非 JVM 应用程序(假设“sidecar”位于“localhost”和端口 8080):

http://localhost:8080/php-sidecar/api/microservice.php

但是,这并没有按预期工作。当我们请求上面的 URI 时,实际上发出了对“localhost:81”的请求,因为不知何故,“sidecar”正在获取它的主机 URI,而不是定义为 sidecar 属性的一部分的 home-page-uri。

如果我们使用 localhost 在本地运行非 JVM 应用程序,那么一切都会按预期运行,但这绝对不是现实的用例。

因此,我在配置中缺少什么来告诉 Spring Cloud(在这种特殊情况下为 Zuul)使用非 JVM 主页 URI 而不是我的本地主机 URI?

感谢您的支持。

【问题讨论】:

    标签: spring spring-cloud netflix-eureka netflix-zuul spring-cloud-netflix


    【解决方案1】:

    经过一番研究,事实证明,sidecar 必须始终与非 JVM 应用程序部署在同一主机上。

    【讨论】:

      【解决方案2】:
      After some research, it turns out that the sidecar must always be deployed in the same host as the non-JVM application.
      
      

      不,您可以将 sidecar.ip-address = 10.135.16.50 添加到您的 yaml 配置文件中

      我使用的是 spring-boot-starter-parent 版本是1.5.6.RELEASE 工作正常

      【讨论】:

        猜你喜欢
        • 2015-04-01
        • 2020-01-18
        • 2015-10-02
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2021-05-30
        相关资源
        最近更新 更多