如何使用 Zuul 路由到另一个端口
How to route to another port with Zuul
我正在尝试将我所有的微服务路由到一个端口为 8080 的路由(商店)
我有一个连接到 Eureka 服务器(端口:8084)的微服务 articlemicroservice。
我也有 zuulservice 连接到 Eureka(运行 在端口 8888 上)。
示例:
http://localhost:8084/articles should be available on http://localhost:8080/articles
我试图在我的 zuul 服务器中的 application.yml 中这样配置它:
eureka:
client:
serviceUrl:
defaultZone: http://localhost:8888/eureka
server:
port: 8079
zuul:
routes:
articlemicroservice:
path: /*
serviceId: articlemicroservice
url: http://localhost:8080/
重要提示:商店(端口:8080)未连接到Eureka。
文章微服务:
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
编辑: 带有 yml 的示例不起作用。
编辑:
尤里卡服务器:
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
我认为您需要一个端口 8080 上的 GatewayApplication,此应用程序将代理部署在任何其他端口下的其他应用程序的请求
- 运行 8080 上的 Zuulproxy
- 运行 前的 ShopMicroService。 8081
- 运行 8084 上的 ArticleMicroService
像这样配置 zuul 路由:
zuul:
routes:
articlemicroservice:
path: /article/**
url: http://localhost:8084/
shopmicroservice:
path: /shop/**
url: http://localhost:8081/
很棒的例子:https://github.com/sqshq/piggymetrics
或者我认为你可以在 ShopMicroService 中使用 @EnableZuulProxy
zuul:
routes:
articlemicroservice:
path: /article/**
url: http://localhost:8084/
我认为没有办法让 ZUUL 在 8079 上工作
我正在尝试将我所有的微服务路由到一个端口为 8080 的路由(商店)
我有一个连接到 Eureka 服务器(端口:8084)的微服务 articlemicroservice。
我也有 zuulservice 连接到 Eureka(运行 在端口 8888 上)。
示例: http://localhost:8084/articles should be available on http://localhost:8080/articles
我试图在我的 zuul 服务器中的 application.yml 中这样配置它:
eureka:
client:
serviceUrl:
defaultZone: http://localhost:8888/eureka
server:
port: 8079
zuul:
routes:
articlemicroservice:
path: /*
serviceId: articlemicroservice
url: http://localhost:8080/
重要提示:商店(端口:8080)未连接到Eureka。
文章微服务:
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
编辑: 带有 yml 的示例不起作用。
编辑:
尤里卡服务器:
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
我认为您需要一个端口 8080 上的 GatewayApplication,此应用程序将代理部署在任何其他端口下的其他应用程序的请求
- 运行 8080 上的 Zuulproxy
- 运行 前的 ShopMicroService。 8081
- 运行 8084 上的 ArticleMicroService
像这样配置 zuul 路由:
zuul: routes: articlemicroservice: path: /article/** url: http://localhost:8084/ shopmicroservice: path: /shop/** url: http://localhost:8081/
很棒的例子:https://github.com/sqshq/piggymetrics
或者我认为你可以在 ShopMicroService 中使用 @EnableZuulProxy
zuul:
routes:
articlemicroservice:
path: /article/**
url: http://localhost:8084/
我认为没有办法让 ZUUL 在 8079 上工作