转发到服务时如何禁用Zuul修改请求URL?

时间:2019-06-25 15:03:33

标签: spring routing netflix-zuul

这是我的Zuul配置(.yml文件)

server:
  port: 8080
zuul:
  sensitiveHeaders:
  ignored-services: "*"
  routes:
    ui-service:
      path: /online-book-store/**
      serviceId: ui-service-v1
      stripPrefix: true
    auth-service:
      path: /auth/**
      serviceId: auth-service
    book-service:
      path: /book-service/**
      serviceId: book-service
    book-service-genres:
      path: /api/genres/**
      serviceId: book-service
  host:
    socket-timeout-millis: 10000
    connect-timeout-millis: 10000


eureka:
  client:
    serviceUrl:
      defaultZone: http://localhost:2580/eureka/

我面临的问题是当我发送请求时:

<zuul_gateway>/api/genres/listAll 

该请求被转发到     <book-service>/listall,我希望它是<book-service>/api/genres/listAll

因此所有“匹配”的路径都将被删除。我如何禁用此“功能”

1 个答案:

答案 0 :(得分:1)

为book-service-genre设置 stripPrefix:false 。默认情况下,匹配的前缀被删除。