Deny access to one particular subpath for spring cloud gateway route

北慕城南 提交于 2019-12-23 05:01:24

问题


We're using Spring Cloud Gateway in front of our backend services. We have a route similar to the following:

  routes:
    - id: foobar-service
      uri: lb://foobar-service
      predicates:
        - Path=/foobar/**
      filters:
        - StripPrefix=1

We want to deny access to one particular subpath (e.g. /foobar/baz/**) but leave the rest open. Is it possible to do this using the YAML syntax? Perhaps we need to implement the routes using the Fluent API instead?


回答1:


  routes:
    - id: foobar-baz-service
      uri: no://op
      predicates:
        - Path=/foobar/baz/**
      filters:
        - SetStatus=403
    - id: foobar-service
      uri: lb://foobar-service
      predicates:
        - Path=/foobar/**
      filters:
        - StripPrefix=1


来源:https://stackoverflow.com/questions/55002994/deny-access-to-one-particular-subpath-for-spring-cloud-gateway-route

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