如何从Zuul路由中排除或忽略特殊路径或路由 [英] How to exclude or ignore special paths or routes from zuul routing
本文介绍了如何从Zuul路由中排除或忽略特殊路径或路由的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
是否可以从Zuul路由中排除路径或匹配器?
Is it possible to exclude paths or matchers from the Zuul routing?
目标是
- 所有对/contracts/** 的请求都路由到 contract.example.com
- 所有对/audit/** 的请求都路由到 audit.example.com
- 所有对/heartbeat/** 或/sso/** 的请求均由zuul直接提供.
- 所有其他请求(/** )被路由到 html.example.com
- All requests to /contracts/** are routed to contract.example.com
- All requests to /audit/** are routed to audit.example.com
- All requests to /heartbeat/** or /sso/** are served from zuul directly.
- All other requests (/**) are routed to 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 ?
Now the question is how to define that /heartbeat and /sso isn't routed to html.example.com by zuul?
我正在使用Spring Boot及其自动配置.
I'm using Spring Boot and its AutoConfiguration.
推荐答案
有一个名为 ignored-patterns 的配置属性.这样,可以定义匹配器以将路由排除在路由之外.
There is a configuration property called ignored-patterns. With this it is possible to define matchers to exclude routes from routing.
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
这篇关于如何从Zuul路由中排除或忽略特殊路径或路由的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文