Add explicit docs for eureka.hostname in secure app registration

Eureka supports native placeholders, but Spring can also be used.
Added some docs to show how more explicitly.

See gh-761
This commit is contained in:
Dave Syer
2016-01-24 08:29:55 +00:00
parent ddd7979a25
commit 92a35ba77f
2 changed files with 26 additions and 7 deletions

View File

@@ -105,9 +105,26 @@ respectively. This will make Eureka publish instance information
showing an explicit preference for secure communication. The Spring
Cloud `DiscoveryClient` will always return an `https://...` URI for a
service configured this way, and the Eureka (native) instance
information will have a secure health check URL. Because of the way
information will have a secure health check URL.
Because of the way
Eureka works internally, it will still publish a non-secure URL for
status and home page unless you also override those explicitly.
You can use placeholders to configure the eureka instance urls,
e.g.
.application.yml
----
eureka:
instance:
statusPageUrl: https://${eureka.hostname}/info
healthCheckUrl: https://${eureka.hostname}/health
homePageUrl: https://${eureka.hostname}/
----
(Note that `${eureka.hostname}` is a native placeholder only available
in later versions of Eureka. You could achieve the same thing with
Spring placeholders as well, e.g. using `${eureka.instance.hostName}`.)
NOTE: If your app is running behind a proxy, and the SSL termination
is in the proxy (e.g. if you run in Cloud Foundry or other platforms

View File

@@ -18,12 +18,12 @@ package org.springframework.cloud.netflix.eureka;
import java.util.Map;
import lombok.extern.apachecommons.CommonsLog;
import com.netflix.appinfo.EurekaInstanceConfig;
import com.netflix.appinfo.InstanceInfo;
import com.netflix.appinfo.LeaseInfo;
import lombok.extern.apachecommons.CommonsLog;
/**
* See com.netflix.appinfo.providers.EurekaConfigBasedInstanceInfoProvider
* @author Spencer Gibb
@@ -40,13 +40,15 @@ public class InstanceInfoFactory {
// server
InstanceInfo.Builder builder = InstanceInfo.Builder.newBuilder();
builder.setNamespace(config.getNamespace())
.setAppName(config.getAppname())
String namespace = config.getNamespace();
if (!namespace.endsWith(".")) {
namespace = namespace + ".";
}
builder.setNamespace(namespace).setAppName(config.getAppname())
.setInstanceId(config.getInstanceId())
.setAppGroupName(config.getAppGroupName())
.setDataCenterInfo(config.getDataCenterInfo())
.setIPAddr(config.getIpAddress())
.setHostName(config.getHostName(false))
.setIPAddr(config.getIpAddress()).setHostName(config.getHostName(false))
.setPort(config.getNonSecurePort())
.enablePort(InstanceInfo.PortType.UNSECURE,
config.isNonSecurePortEnabled())