【问题标题】:Spring cloud Zuul url configurationSpring Cloud Zuul url 配置
【发布时间】:2023-03-11 10:32:01
【问题描述】:

我正在尝试使用 zuul 和 Eureka 服务器运行示例。

以下是我的配置:

eureka-service 

server.port=8761

eureka.client.register-with-eureka=false
eureka.client.fetch-registry=false

logging.level.com.netflix.eureka=OFF
logging.level.com.netflix.discovery=OFF

eureka -client (bootstrap.properties):

spring.application.name=ab
management.server.port=9001
management.server.address: 127.0.0.1
server.port=8081

edge-service(zuul) :

zuul.routes.ab.url=http://localhost:8081
ribbon.eureka.enabled=false
spring.application.name=API-Gateway
eureka.client.eureka-server-port=8761
server.port=8080

当我点击 URL http:localhost:8080/clientapi 时,我得到一个白标错误页面,似乎缺少什么配置,因为我可以看到 edge-service 以及 eureka-client 已正确注册尤里卡服务器。

我使用的是弹簧靴:2.1.4。

【问题讨论】:

  • zuul的日志里有什么?和尤里卡服务器(但你已经把它关掉了)?

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


【解决方案1】:

让我告诉你我的例子:

application.yml 文件中的 eureka:

server:
  port: 8761

eureka:
  client:
    register-with-eureka: false
    fetch-registry: true
    instance-info-replication-interval-seconds: 10
  server:
    eviction-interval-timer-in-ms: 50000
    wait-time-in-ms-when-sync-empty: 5

祖尔:

zuul.routes.1.url=http://localhost:8081
zuul.routes.2.url=http://localhost:8082

zuul.prefix=/client

zuul.host.max-per-route-connections=10
zuul.host.max-total-connections=10

我有 2 个服务(1 - localhost:8081 和 2 - localhost:8082)

你需要注解主类Zuul:

@EnableZuulProxy
@EnableDiscoveryClient

然后启动应用程序。当你去

localhost/8070/client/1

您将重定向到第一个服务 (localhost:8081) 当你去

localhost/8070/client/2

希望对你有帮助。

您将重定向到第二个服务 (localhost:8082)

【讨论】:

    猜你喜欢
    • 2018-08-10
    • 2016-06-05
    • 1970-01-01
    • 1970-01-01
    • 2017-09-29
    • 2018-01-23
    • 2019-02-12
    • 2016-09-20
    • 2018-02-02
    相关资源
    最近更新 更多