Commit 92a35ba7 by Dave Syer

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
parent ddd7979a
......@@ -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
......
......@@ -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())
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment