Spring Cloud Sidecar没有按预期工作

时间:2016-04-20 10:47:22

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

根据文档,@ 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}/

&#34; sidecar&#34;启动并运行,我们应该能够通过服务注册表调用其中一个非JVM端点,只需使用&#34; sidecar&#34;用于在Eureka注册的申请。例如,如果我们的&#34; sidecar&#34;申请在Eureka注册为&#34; php-sidecar&#34;使用端点代理PHP应用程序,例如:

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

然后我们应该能够调用以下端点来访问非JVM应用程序(假设&#34; sidecar&#34;在&#34; localhost&#34;和端口8080):

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

但是,这没有按预期工作。当我们在上面请求URI时,请求&#34; localhost:81&#34;实际上是发行的,因为不知何故的&#34; sidecar&#34;正在拿起它的主机URI,而不是主页 - uri被定义为sidecar的属性的一部分。

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

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

感谢您的支持。

2 个答案:

答案 0 :(得分:0)

经过一番研究后发现,必须始终将sidecar部署在与非JVM应用程序相同的主机中。

答案 1 :(得分:0)

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 工作正常

相关问题