因为目前的Spring Cloud的中文资料真的很少,stripPrefix,先来了解一下什么是Prefix,有一个叫zuul.prefix,zuul.prefix=/api用户微服务和eureka已经起好了,看一下prefix是干嘛用的localhost:8040/api/microservice-simple-provider-user/simple/1前缀加上用户微服务的id,微服务的路径,prefix是干这个用的,stripPrefix是干嘛用的呢,选项默认是truezuul:routes:users:path: /myusers/**stripPrefix: falsezuul.strip-prefix=false
zuul.routes.user-route.stripPrefix=false剥掉前缀,设置成false,localhost:8040/api/microservice-simple-provider-user/simple/1这个路径访问不了是把api/这个去掉吗localhost:8040/microservice-simple-provider-user/simple/1也访问不了,我们借助日志loggin.level.com.netflix=debuglogging.level.com.learn=trace
logging.file=springboot.log
logging.pattern.console=%d{yyyy-MM-dd} [%thread] %-5level %logger{50} - %msg%n
logging.pattern.file=%d{yyyy-MM-dd} ==== [%thread] %-5level ==== %logger{50} ==== %msg%n我们看他请求到了什么地址,我们访问这个localhost:8040/api/microservice-simple-provider-user/simple/1看到请求到哪里zuul.prefix=/simple
zuul.stripPrefix=falselocalhost:8040/simple/microservice-simple-provider-user/simple/1也就是zuul代理的微服务的前缀,homePage是7900,有的微服务可能设置了context-path,localhost:7900/simple/1zuul.prefix=/simplelocalhost:8040/simple/microservice-simple-provider-user/simple/1zuul.prefix=/simple
zuul.stripPrefix=truehttps://github.com/spring-cloud/spring-cloud-netflix/issues/1365zuul.stripPrefix=false not work for all route? #1365zuul.stripPrefix specifically applies to zuul.prefix. zuul.routes.<route>.stripPrefix applies to zuul.routes.<route>.pathzuul:ignoredPatterns: /**/admin/**routes:users: /myusers/**忽略某些敏感的路径zuul:ignoredServices: '*'routes:users: /myusers/**ignoredServices是粗粒度的忽略,他忽略的整个微服务https://blog.csdn.net/kevin_loving/article/details/80661259ignoredPatterns这个就可以做到更细粒度的忽略,忽略某些路径,这样配这里解释的很好,https://cloud.spring.io/spring-cloud-netflix/reference/html/#_ignored_headersThe preceding example means that all calls (such as /myusers/101) are forwarded to /101 on the users service. However, calls including /admin/ do not resolve.zuul:ignoredPatterns: /**/admin/**routes:users: /myusers/**zuul:routes:users:path: /myusers/**legacy:path: /**users下是/myusers/**这么玩的,剩下的是/**这么玩的,叫legacy路由,你想利用rule的order,所谓的优先级了,现在优先级是什么,order是什么,你得用yaml,否则这个特性玩不起来If you were to use a properties file, the legacy path might end up in front of the users path, rendering the users path unreachable.所有的路由都讲到这里
server.port=8040
spring.application.name=microservice-gateway-zuul-reg-exp
eureka.instance.prefer-ip-address=true
eureka.instance.instance-id=${spring.application.name}:${spring.cloud.client.ipAddress}:${spring.application.instance_id:${server.port}}
eureka.client.serviceUrl.defaultZone=http://admin:1234@10.40.8.152:8761/eureka
eureka.instance.appname=microservice-gateway-zuul-reg-exp
#zuul.prefix=/api
#zuul.routes.user-route.stripPrefix=false
zuul.prefix=/simple
zuul.stripPrefix=true
logging.level.com.learn=trace
logging.file=springboot.log
logging.pattern.console=%d{yyyy-MM-dd} [%thread] %-5level %logger{50} - %msg%n
logging.pattern.file=%d{yyyy-MM-dd} ==== [%thread] %-5level ==== %logger{50} ==== %msg%n

Zuul路由的strip-prefix与order相关推荐

  1. Spring Cloud(八)Zuul路由网关

    文章目录 1 概述 1.1 什么是Zuul 1.2 为什么要建造Zuul 1.3 Zuul有哪些功能 1.4 理解 2 Zuul路由功能 2.1 创建zuul服务 2.2 测试 2.3 路由访问映射规 ...

  2. 【七】zuul路由网关

    一.zuul是什么?zuul 包含以下两个最主要的功能:1.路由功能: 负责将外部请求转发到具体的微服务实例上,是实现外部访问统一入口的基础.2.过滤器功能: 则负责对请求的处理过程进行干预,是实现请 ...

  3. 跟着狂神学SpringCloud(Rest环境搭建+Eureka服务注册与发现+ribbon+Feign负载均衡+Hystrix+服务熔断+Zuul路由网关+SpringCloud config分布)

    跟着狂神学SpringCloud SpringCloud 回顾之前的知识- JavaSE 数据库 前端 Servlet Http Mybatis Spring SpringMVC SpringBoot ...

  4. SpringCloud(第 025 篇)Zuul 路由后面的微服务挂了后,Zuul 提供了一种回退机制来应对熔断处理...

    2019独角兽企业重金招聘Python工程师标准>>> SpringCloud(第 025 篇)Zuul 路由后面的微服务挂了后,Zuul 提供了一种回退机制来应对熔断处理 一.大致 ...

  5. SpringCloud学习系列之七 ----- Zuul路由网关的过滤器和异常处理

    前言 在上篇中介绍了SpringCloud Zuul路由网关的基本使用版本,本篇则介绍基于SpringCloud(基于SpringBoot2.x,.SpringCloud Finchley版)中的路由 ...

  6. zuul如果两个filter的order一样,是如何排序的?

    引言 最近有个网友问了一个问题,zuul中如果两个filter的order一样,是如何排序的?引起了我的兴趣,特地去阅读了它的源码. zuul是干什么的 如果你有使用过springcloud应该听说过 ...

  7. Zuul路由网关--配置讲解

    1:什么是zuul,用什么用? Zuul是Netflix开源的微服务网关,可以和Eureka.Ribbon.Hystrix等组件配合使用,Spring Cloud对Zuul进行了整合与增强,Zuul的 ...

  8. zuul 路由不生效_springBoot集成zuul路由forward,设置setSendZuulResponse无效

    正确书写方式如下: 1 RequestContext ctx =RequestContext.getCurrentContext();2 ctx.setSendZuulResponse(false); ...

  9. SpringCloud:Zuul 路由访问(基本使用、路由功能、过滤访问、服务降级)

    在现在为止所有的微服务都是通过 Eureka 找到的,但是在很多的开发之中为了规范微服务的使用,提供有一个路由的处理控制组件:Zuul,也就是说 Zuul 就作为中间的一个代理层出现.2.1.Zuul ...

最新文章

  1. python中字符串的布尔值_Python基础之字符串,布尔值,整数,列表,元组,字典,集合...
  2. CSS揭秘之《背景图案》
  3. 【例3.5】位数问题
  4. oracle数据库连接时报12514_Oracle 数据库 SQLPlus连接正常、PLSQL连接报错 ORA-12514、TNSPING正常...
  5. JavaScript实现breadth First Search广度优先搜索算法(附完整源码))
  6. python创建新进程_Python:创建新进程
  7. python 无头浏览器xhr 文件_Python对Selenium调用浏览器进行封装包括启用无头浏览器,及对应的浏览器配置文件...
  8. JAVA并发编程的挑战
  9. 在c语言中realloc_C和C ++编程中的realloc()
  10. 安川机器人dx200编程手册_【安川 】一文带了解DX200如何编程(上)
  11. php生成成语,在线成语词典 洪恩在线成语词典小偷程序php版
  12. 在线图片托管服务imgur
  13. 三天搞定射频识别技术(一)1.3
  14. gitbub遇见的问题
  15. doxygen的特定命令
  16. 嵌入式开发基本环境搭建---ubuntu
  17. 根据业绩确定提成比例并计算提成
  18. PRTG - Paessler Router Traffic Grapher 6.0.5.516/517 软件试用
  19. 功放前级的左右_都是功放,前级和后级差别甚大!千万别买错了
  20. 工具类--GeneralUtil

热门文章

  1. C# 参数化SQL语句中的like和in
  2. 漂亮表格的CSS定义
  3. js高级技巧之柯里化
  4. Activiti 7.1.4 发布,业务流程管理与工作流系统
  5. AIX上报:“Shell will time out in 60 seconds” 解决办法
  6. 记下MD5验签可能出现的问题
  7. Stimulsoft Reports.Net基础教程(七):创建列式报表①
  8. android studio 导入第三方库的记录
  9. Singleton设计模式(单实例)
  10. ubuntu系统操作常见错误