Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Publish custom port to eureka service registry from eureka client #4056

Open
an0nh4x0r opened this issue Dec 26, 2021 · 7 comments
Open

Publish custom port to eureka service registry from eureka client #4056

an0nh4x0r opened this issue Dec 26, 2021 · 7 comments
Assignees

Comments

@an0nh4x0r
Copy link

an0nh4x0r commented Dec 26, 2021

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

@OlgaMaciaszek
Copy link
Collaborator

Hello @an0nh4x0r, why do you need this functionality? Could you describe your use-case in more details?

@an0nh4x0r
Copy link
Author

an0nh4x0r commented Jan 17, 2022

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.

@OlgaMaciaszek
Copy link
Collaborator

@an0nh4x0r thanks for the details. Will discuss it with the team and get back to you.

@OlgaMaciaszek
Copy link
Collaborator

@an0nh4x0r Actually, you should be able to set it using these props. Let me know if this solves your issue.

@spring-cloud-issues
Copy link

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.

@spring-cloud-issues
Copy link

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.

@madmurl0c
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants