小编典典

如何从zuul路由中排除或忽略特殊路径或路由

spring-boot

是否可以从Zuul路由中排除路径或匹配器?

目标是

  • 所有对 / contracts / **的 请求都路由到 contract.example.com
  • 所有对 / audit / **的 请求都路由到 audit.example.com
  • / heartbeat / / sso / 所有请求均直接从zuul获得。
  • 所有其他请求( / ** )都路由到 html.example.com

我有这样的配置:

zuul:
    routes:
        contract:
            path: /contracts/**
            url: http://contracts.example.com:8080/api
        audit:
            path: /audits/**
            url: http://audit.example.com:8080
        html:
            path: /**
            url: http://html.example.com:80

现在的问题是如何定义 zuul 不将 / heartbeat/ sso 路由到html.example.com? __

我正在使用Spring Boot及其自动配置。


阅读 666

收藏
2020-05-30

共1个答案

小编典典

有一个配置属性,称为 ignore-patterns 。这样,可以定义匹配器以将路由排除在路由之外。

zuul:
    ignoredPatterns:
        - /heartbeat/**
        - /sso/**
    routes:
        contract:
            path: /contracts/**
            url: http://contracts.example.com:8080/api
        audit:
            path: /audits/**
            url: http://audit.example.com:8080
        html:
            path: /**
            url: http://html.example.com:80
2020-05-30