【问题标题】:Can Zuul Edge Server be used without Eureka / Ribbon没有Eureka / Ribbon可以使用Zuul Edge Server吗
【发布时间】:2016-03-06 07:46:35
【问题描述】:

我们有一个具有服务发现和负载平衡的基础设施(即带有 STM 和 weblogic 集群的服务器端)。现在我们正在重构为微服务。我们需要一个 API 网关来执行到其他微服务的基本路由。 Netflix Zuul 看起来是一个不错的候选者,但是如果没有 Eureka,我无法让 Zuul 工作 - 但我们不需要 Eureka,因为我们已经有了服务发现和负载平衡。

  1. 是否可以在没有 Eureka 和 Ribbon 的情况下使用 Zuul?
  2. 如果是,请提供一些行规,因为 wiki 中没有提及。

谢谢。

【问题讨论】:

    标签: spring-cloud netflix netflix-eureka netflix-zuul


    【解决方案1】:

    是的,当然可以。实际上,默认情况下,如果您将 @EnableZuulProxy 与 Spring Boot Actuator 一起使用,则会启用两个额外的端点:

    • 路线
    • 过滤器

    application.yaml

    zuul:
      routes:
        users:
          path: /myusers/**
          url: https://example.com/users_service
    

    这些简单的 url-routes 不会作为 HystrixCommand 执行,也不会使用 Ribbon 对多个 URL 进行负载平衡。

    您可以从here获取更多信息。

    【讨论】:

      【解决方案2】:

      示例用法如下:

      shared.microservice.customer.service1.url=zttp://127.0.0.1:8080/shared/microservice/customer/
      
      shared.microservice.customer.service2.url=zttp://127.0.0.1:8181/shared/microservice/customer/
      
      ribbon.eureka.enabled = false
      
      zuul.routes.customer-micro-service.path: /shared/microservice/customer/**
      
      zuul.routes.customer-micro-service.serviceId: customers
      customers.ribbon.listOfServers = 
      
      zttp://ip:port1/shared/microservice/customer/,zttp://ip2:port2/shared/microservice/customer/
      

      【讨论】:

        【解决方案3】:

        是的,这是完全可能的。你必须在你的配置类上使用@EnableZuulProxy 并像这样配置它:

        zuul:
          routes:
            yourService:
              path: /yourService/**
              serviceId: yourService
        
        ribbon:
          eureka:
            enabled: false
        
        yourService:
          ribbon:
            listOfServers: localhost:8080
        

        【讨论】:

        • 你也可以把url放在yourService下面。
        • 如果我使用spring-cloud会怎样?
        • 所有这些更改都在 Zuul 配置中,对吗?我应该对微服务“yourService”进行任何更改吗?
        • 这些都是zuul,是的。下游服务无需更改。另外,spring 现在有了自己的网关,如果你刚刚开始,我建议你去看看:cloud.spring.io/spring-cloud-gateway
        猜你喜欢
        • 2019-08-04
        • 2016-02-01
        • 2015-12-12
        • 2019-03-20
        • 1970-01-01
        • 2018-04-09
        • 2018-09-29
        • 2020-10-15
        • 2020-06-26
        相关资源
        最近更新 更多