Reputation: 601
I am trying to route all of my microservices to one route with the port 8080 (shop)
I have a microservice articlemicroservice that is connected to an Eureka Server (port:8084).
I do also have zuulservice connected to Eureka (running on Port 8888).
Example: http://localhost:8084/articles should be available on http://localhost:8080/articles
I tried to configure it in my application.yml in my zuul server like this:
eureka:
client:
serviceUrl:
defaultZone: http://localhost:8888/eureka
server:
port: 8079
zuul:
routes:
articlemicroservice:
path: /*
serviceId: articlemicroservice
url: http://localhost:8080/
Important: Shop (Port:8080) is not connected to Eureka.
ArticleMicroService:
server.port=8084
spring.application.name=articlemicroservice
eureka.client.serviceUrl.defaultZone=http://localhost:8888/eureka/
eureka.client.fetchRegristry=true
eureka.instance.preferIpAddress=true
ShopMicroService:
server.port=8080
spring.application.name=shopmicroservice
Edit: The example with the yml did not work.
Edit:
Eureka Server:
server.port=8888
spring.application.name=eurekaserver
eureka.client.register-with-eureka=false
eureka.client.fetch-registry=false
eureka.client.service-url.defaultZone=http://localhost:8888/eureka/
eureka.instance.lease-expiration-duration-in-seconds:2
Upvotes: 3
Views: 2789
Reputation: 56
I think you need one GatewayApplication on port 8080, this application will proxy requests for other applications deployed under any other ports
Configure zuul routes like:
zuul:
routes:
articlemicroservice:
path: /article/**
url: http://localhost:8084/
shopmicroservice:
path: /shop/**
url: http://localhost:8081/
awesome example : https://github.com/sqshq/piggymetrics
OR I think you can @EnableZuulProxy in ShopMicroService
zuul:
routes:
articlemicroservice:
path: /article/**
url: http://localhost:8084/
I don't think there is a way to make ZUUL works on 8079
Upvotes: 3