I'm learning about Microservices with Eureka & Spring Boot. I've already known how and successfully registered all services into Eureka, but all services and Eureka are created on Localhost. I wonder, can I stores services from other computer and still be able to register to Eureka in this Computer, and how to do it? Is there any documents for my question? Because I looked up to Eureka documents and all of them are about create eureka and services only on localhost. Thank you everyone!
Here is my eureka-server: application.properties
spring.application.name=netflix-eureka-server
server.port=8761
eureka.client.register-with-eureka=false
eureka.client.fetch-registry=false
Here is my product-management-service: application.properties
spring.application.name=product-management-service
eureka.client.service-url.default-zone=http://localhost:8761/eureka
server.port=8077
I've found the solution for my problem Firstly, I add 2 more lines of code to application.properties of my computer xxx.xxx.xxx.166 which to tell eureka from this computer that services will register from IP address xxx.xxx.xxx.124:
spring.application.name=netflix-eureka-server
server.port=8761
eureka.client.register-with-eureka=false
eureka.client.fetch-registry=false
#add these lines which is the IP address of my another computer
spring.cloud.discovery.client.simple.local.uri=http://xxx.xxx.xxx.124
eureka.instance.appname=xxx.xxx.xxx.124
Secondly, I config application.properties of my Another computer by add some lines to file:
spring.application.name=product-management-service
eureka.client.service-url.default-zone=http://localhost:8761/eureka
#new code start here
eureka.client.prefer-same-zone-eureka=false
eureka.client.proxy-host=xxx.xxx.xxx.166
eureka.client.proxy-port=8761
server.address=192.168.11.124
server.port=8077
#configuration to set the ip of host instead of the default localhost
eureka.instance.prefer-ip-address=true
eureka.instance.hostname=${server.address}
eureka.instance.ip-address=${server.address}
eureka.instance.instance-id=${server.address}:${spring.application.name}:${server.port}
#new code end here
And here is my result Eureka.
I hope to see more and better suggestion about this situation from everyone.
Hope this could help someone xD.