How to exclude or ignore special paths or routes from zuul routing

吃可爱长大的小学妹 提交于 2019-12-12 10:44:33

问题


Is it possible to exclude paths or matchers from the Zuul routing?

The goal is that

  • 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

I have configuration like this:

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

Now the question is how to define that /heartbeat and /sso isn't routed to html.example.com by zuul?

I'm using Spring Boot and its AutoConfiguration.


回答1:


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



回答2:


As of Brixton.SR6 the ignoredPattern properties should be defined different in the application.yml file. It should be defined as follows:

zuul:
ignoredPatterns: /heartbeat/**, /sso/**
routes:
    contract:
        path: /contracts/**
        url: http://contracts.example.com:8080/api


来源:https://stackoverflow.com/questions/37167629/how-to-exclude-or-ignore-special-paths-or-routes-from-zuul-routing

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!