diff --git a/spring-cloud-netflix-sidecar/pom.xml b/spring-cloud-netflix-sidecar/pom.xml
index ad30ed54..8ed7203e 100644
--- a/spring-cloud-netflix-sidecar/pom.xml
+++ b/spring-cloud-netflix-sidecar/pom.xml
@@ -73,5 +73,10 @@
spring-boot-starter-test
test
+
+ org.springframework.cloud
+ spring-cloud-config-client
+ test
+
diff --git a/spring-cloud-netflix-sidecar/src/main/java/org/springframework/cloud/netflix/sidecar/LocalApplicationHealthIndicator.java b/spring-cloud-netflix-sidecar/src/main/java/org/springframework/cloud/netflix/sidecar/LocalApplicationHealthIndicator.java
index a0b5095b..6e758e14 100644
--- a/spring-cloud-netflix-sidecar/src/main/java/org/springframework/cloud/netflix/sidecar/LocalApplicationHealthIndicator.java
+++ b/spring-cloud-netflix-sidecar/src/main/java/org/springframework/cloud/netflix/sidecar/LocalApplicationHealthIndicator.java
@@ -19,7 +19,7 @@ public class LocalApplicationHealthIndicator extends AbstractHealthIndicator {
@SuppressWarnings("unchecked")
@Override
protected void doHealthCheck(Health.Builder builder) throws Exception {
- URI uri = properties.getLocalHealthUri();
+ URI uri = properties.getHealthUri();
if (uri == null) {
builder.up();
return;
diff --git a/spring-cloud-netflix-sidecar/src/main/java/org/springframework/cloud/netflix/sidecar/SidecarConfiguration.java b/spring-cloud-netflix-sidecar/src/main/java/org/springframework/cloud/netflix/sidecar/SidecarConfiguration.java
index 99b48b83..191df1d2 100644
--- a/spring-cloud-netflix-sidecar/src/main/java/org/springframework/cloud/netflix/sidecar/SidecarConfiguration.java
+++ b/spring-cloud-netflix-sidecar/src/main/java/org/springframework/cloud/netflix/sidecar/SidecarConfiguration.java
@@ -1,7 +1,9 @@
package org.springframework.cloud.netflix.sidecar;
+import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.autoconfigure.condition.ConditionalOnExpression;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
+import org.springframework.cloud.netflix.eureka.EurekaInstanceConfigBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
@@ -12,12 +14,30 @@ import org.springframework.context.annotation.Configuration;
@EnableConfigurationProperties
@ConditionalOnExpression("${sidecar.enabled:true}")
public class SidecarConfiguration {
+ @Value("${server.port:${SERVER_PORT:${PORT:8080}}}")
+ private int serverPort = 8080;
@Bean
public SidecarProperties sidecarProperties() {
return new SidecarProperties();
}
+ @Bean
+ public EurekaInstanceConfigBean eurekaInstanceConfigBean() {
+ EurekaInstanceConfigBean config = new EurekaInstanceConfigBean();
+
+ int port = sidecarProperties().getPort();
+ config.setNonSecurePort(port);
+
+ String scheme = config.getSecurePortEnabled()? "https" : "http";
+
+ config.setStatusPageUrl(scheme + "://" + config.getHostname() + ":" + serverPort + config.getStatusPageUrlPath());
+ config.setHealthCheckUrl(scheme + "://" + config.getHostname() + ":" + serverPort + config.getHealthCheckUrlPath());
+
+ config.setHomePageUrl(scheme + "://" + config.getHostname() + ":" + port + config.getHomePageUrlPath());
+ return config;
+ }
+
@Bean
public LocalApplicationHealthIndicator localApplicationHealthIndicator() {
return new LocalApplicationHealthIndicator();
diff --git a/spring-cloud-netflix-sidecar/src/main/java/org/springframework/cloud/netflix/sidecar/SidecarProperties.java b/spring-cloud-netflix-sidecar/src/main/java/org/springframework/cloud/netflix/sidecar/SidecarProperties.java
index 052c9c98..4f519e9f 100644
--- a/spring-cloud-netflix-sidecar/src/main/java/org/springframework/cloud/netflix/sidecar/SidecarProperties.java
+++ b/spring-cloud-netflix-sidecar/src/main/java/org/springframework/cloud/netflix/sidecar/SidecarProperties.java
@@ -11,5 +11,7 @@ import java.net.URI;
@Data
@ConfigurationProperties("sidecar")
public class SidecarProperties {
- private URI localHealthUri;
+ private URI healthUri;
+ private URI homePageUri;
+ private int port;
}
diff --git a/spring-cloud-netflix-sidecar/src/test/resources/application.yml b/spring-cloud-netflix-sidecar/src/test/resources/application.yml
index 14912394..7bba61ae 100644
--- a/spring-cloud-netflix-sidecar/src/test/resources/application.yml
+++ b/spring-cloud-netflix-sidecar/src/test/resources/application.yml
@@ -5,7 +5,20 @@ spring:
name: sidecarTest
sidecar:
- local-health-uri: http://localhost:8081/health
+ port: 8000
+ health-uri: http://localhost:8000/src/test/resources/health.json
+
+eureka:
+ instance:
+ app-group-name: mysidecargroup
+
+endpoints:
+ refresh:
+ enabled: true
+ shutdown:
+ enabled: true
+ health:
+ sensitive: false
zuul:
proxy: