Search code examples
springspring-cloudnetflix-eurekanetflix-zuulspring-cloud-netflix

Spring Cloud Sidecar is not working as expected


Based on the documentation, the @EnableSidecar annotation acts as a proxy for non-JVM applications that wish to register in Eureka. Accordingly, the configuration to be set is:

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}/

Once the "sidecar" is up and running, we should be able to invoke one of the non-JVM endpoints through the service registry just by using the name that the "sidecar" application used to register in Eureka. So for example, if our "sidecar" application was registered in Eureka as "php-sidecar" to proxy a PHP application with an endpoint such as:

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

Then we should be able to invoke the following endpoint to get to the non-JVM application (assuming "sidecar" is in "localhost" and port 8080):

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

However, this is not working as expected. When we request the URI just above, a request to "localhost:81" is actually issued, because somehow the "sidecar" is picking up its host URI and not the home-page-uri defined as part of the sidecar's properties.

If we run the non-JVM application locally using localhost, then everything works as expected, but this is definitively not the realistic use case.

Therefore, what am I missing in my configuration to tell Spring Cloud (Zuul in this particular case) to use the non-JVM home-page-uri and not my local host URI?

Thanks for your support.


Solution

  • After some research, it turns out that the sidecar must always be deployed in the same host as the non-JVM application.