Eureka client by default publishes ${server.port}
to service registery i.e. eureka server. There needs to be a property where we can publish custom port to service registry
There needs to be a property called ${eureka.instance.custom-port}
which can be used to set custom port which will then get published to the eureka server ... instead of ${server.port}
In my organization , I've override a bean called eurekaInstanceConfigBean
basically at this line here in class EurekaClientAutoConfiguration
I'm checking for custom port property and if it's present I'm using custom port instead of ${server.port}
and publishing that port instead. It works great for me
I would like to get this property support officially from the library
Comment From: OlgaMaciaszek
Hello @an0nh4x0r, why do you need this functionality? Could you describe your use-case in more details?
Comment From: an0nh4x0r
Hey @OlgaMaciaszek ... We have our own cloud in my company where we run custom built containers(not docker) ... We basically have two ports i.e. first inner port of which spring boot is running, second outer port through which traffic gets port forwarded to this inner port in which spring boot app runs ... I have access to outer port number in container through enviornment variable ... I was looking for ways to publish this outer port to eureka service registery. In my company I see people who are using zookeeper as service registery have option to publish custom port to zookeeper ... I was looking to get same functionality natively from Eureka client.
Comment From: OlgaMaciaszek
@an0nh4x0r thanks for the details. Will discuss it with the team and get back to you.
Comment From: OlgaMaciaszek
@an0nh4x0r Actually, you should be able to set it using these props. Let me know if this solves your issue.
Comment From: spring-cloud-issues
If you would like us to look at this issue, please provide the requested information. If the information is not provided within the next 7 days this issue will be closed.
Comment From: spring-cloud-issues
Closing due to lack of requested feedback. If you would like us to look at this issue, please provide the requested information and we will re-open the issue.
Comment From: madmurl0c
I am not the original creator of this issue but I'm experiencing a similar issue.
Here's the required part of my application.yml:
eureka:
instance:
hostname: ${EUREKA_HOSTNAME:localhost}
securePort: ${EUREKA_PORT:443}
server:
port: '443'
http:
port: '80'
I want spring to use the default ports for http/https inside of docker (easier integration into out stacks) but eureka should advertise the "external" port.
Since this didn't have the effect I wanted I tried it like this:
@Value("${eureka.instance.securePort}")
private int eurekaInstanceSecurePort;
@Bean
public EurekaInstanceConfigBean eurekaInstanceConfig(InetUtils inetUtils) {
EurekaInstanceConfigBean bean = new EurekaInstanceConfigBean(inetUtils);
System.out.println("Override port: " + eurekaInstanceSecurePort);
bean.setSecurePortEnabled(true);
bean.setSecurePort(eurekaInstanceSecurePort);
return bean;
}
If I use this command docker run -p 30001:443 -e EUREKA_PORT=30001 -e EUREKA_HOSTNAME=server01 ...
eureka still reports the port 443 and not 30001.
The log looks like this:
Override port: 30001
...
EurekaAutoServiceRegistration : Updating port to 443
If you need any more info please let me know
Comment From: OlgaMaciaszek
Hello @madmurl0c, please provide a minimal, complete, verifiable example that reproduces the issue as a link to a separate GitHub repo with an executable app and steps to reproduce.
Comment From: spring-cloud-issues
If you would like us to look at this issue, please provide the requested information. If the information is not provided within the next 7 days this issue will be closed.
Comment From: spring-cloud-issues
Closing due to lack of requested feedback. If you would like us to look at this issue, please provide the requested information and we will re-open the issue.