Search code examples
amazon-ec2spring-cloudnetflix-eurekanetflix-zuul

Netflix eureka client registering with eureka discovery server using private DNS instead of public DNS or public IP in AWS ec2


I am implementing micro service Netflix stack using spring cloud. Everything was going well but here is one problem.

My discovery server is hosted on digital ocean droplet. All of my eureka client from digital ocean are responding well. But one of my client is hosted in aws ec2 midium instance. After running my client it is connected with eureka server successfully. Eureka server showing my instance in dashboard but it's status is showing private DNS instead of public DNS or public IP. For this reason my zuul gateway is not connecting with that aws instance.

My question is:

  • How can my eureka client connect using public IP or public DNS with my eureka discovery server
  • This problem is also exists in docker deployment of my eureka client

Here is my eureka client's application.yml file:

# Spring properties
spring:
  application:
    name: product-service

# HTTP Server
server:
  port: 9090
  servlet:
      context-path: /product-service

my_message:server 5050

# Discovery Server Access
eureka:
  client:
    serviceUrl:
                  defaultZone: http://xx.xx.xx.xx:8080/discovery-server/eureka/
    instance:
      leaseRenewalIntervalInSeconds: false

management:
  security:
    enabled: false

Here is screen shoot enter image description here


Solution

  • YES, finally i figured out of my problem and solved that issue in my server.

    Analysis of problem:

    • In docker case eureka client is registering with eureka server using it's internal ip and port.
    • In aws ec2 case eureka client is registering with eureka server using it's private ip address and port.

    For both cases, Netflix ribbon was calling eureka client using their provided ip. For this reason ribbon was failed to call expected client .

    Solution:

    Provide eureka instance the expected IP address and connect with eureka server using that IP address.

    Just add bellow lines in eureka clients application.yml file:

    eureka:
      instance:
        prefer-ip-address : true
        ip-address : xx.xx.xx.xx
    

    Thanks :)