ZuulProxy在转发请求时删除路由路径

时间:2019-06-03 17:49:53

标签: spring spring-boot netflix-zuul

问题是我需要发送请求而不从初始请求中删除路径

这是我的配置:

zuul: 
    sensitive-headers: Cookie,Set-Cookie
    host:
        max-total-connections: 1000
        max-per-route-connections: 100
        connect-timeout-millis: 10000
        connection-request-timeout-millis: 100000
    semaphore:
        max-semaphores: 500
    routes:
        carriers:
            path: /users/**
            serviceId: users-service

当请求转发到服务时,它被发送而没有路径,在这种情况下为/ users /。

因此在服务端,我得到GET /而不是GET /users/

是否可以通过某种方式配置保留路径部分?

1 个答案:

答案 0 :(得分:1)

是的,可以保存最初匹配的path部分。

您需要将stripPrefix选项设置为false

因此最终配置如下:

zuul: 
    sensitive-headers: Cookie,Set-Cookie
    host:
        max-total-connections: 1000
        max-per-route-connections: 100
        connect-timeout-millis: 10000
        connection-request-timeout-millis: 100000
    semaphore:
        max-semaphores: 500
    routes:
        carriers:
            path: /users/**
            stripPrefix: false
            serviceId: users-service

希望这会有所帮助。