spring-cloud / spring-cloud-gateway

An API Gateway built on Spring Framework and Spring Boot providing routing and more.
http://cloud.spring.io
Apache License 2.0
4.51k stars 3.31k forks source link

StripPrefix delete uri path prefix forwarding, the number of deletions is incorrect #2030

Closed walter9088 closed 3 years ago

walter9088 commented 3 years ago

I encountered a problem with StripPrefix configuration forwarding

I want to use StripPrefix to remove the first few digits of the path prefix of my uri request, which can work normally in the case of large amounts of data. But there are a few requests that are on the wrong path when forwarded downward.

case:

predicates Path=/api/userdevice/aa/xxxx filters StripPrefix=2 I hope the request path forwarded is : /aa/xxxx

But the following path will appear: /userdevice/aa/xxxx

ctlove0523 commented 3 years ago

I make simple example to test StripPrefixGatewayFilterFactory,but it works well,can your post your configure and test codes?(I guess you may call /api/userdevice/userdevice/aa/xxxx)

walter9088 commented 3 years ago

Through performance measurement, I found that OpenStripPrefixGatewayFilterFactory.Config did not get the correct parts.

one hours testing ,This problem was reproduced 5 times. the config in apollo: spring.cloud.gateway.routes[3].id = xxxx spring.cloud.gateway.routes[3].uri = lb://xxx spring.cloud.gateway.routes[3].predicates[0] = Path=/api/userdevice/** spring.cloud.gateway.routes[3].filters[0] = AddRequestHeader=code, META spring.cloud.gateway.routes[3].filters[1] = StripPrefix=2 spring.cloud.gateway.routes[3].filters[2].name = Retry spring.cloud.gateway.routes[3].filters[2].args[retries] = 3 spring.cloud.gateway.routes[3].filters[2].args[series] = SERVER_ERROR spring.cloud.gateway.routes[3].filters[2].args[methods] = POST spring.cloud.gateway.routes[3].order = 3

ctlove0523 commented 3 years ago

@walter9088 thanks for your feedback,i will create a long time run test to reproduce this issue.

walter9088 commented 3 years ago

Ok, I'm also investigating the specific reasons, and will continue to sync if there is evidence

walter9088 commented 3 years ago

spring-boot-starter-parent version:2.1.13.RELEASE

Greenwich.SR5
nearspears commented 3 years ago

Through performance measurement, I found that OpenStripPrefixGatewayFilterFactory.Config did not get the correct parts.

one hours testing ,This problem was reproduced 5 times. the config in apollo: spring.cloud.gateway.routes[3].id = xxxx spring.cloud.gateway.routes[3].uri = lb://xxx spring.cloud.gateway.routes[3].predicates[0] = Path=/api/userdevice/** spring.cloud.gateway.routes[3].filters[0] = AddRequestHeader=code, META spring.cloud.gateway.routes[3].filters[1] = StripPrefix=2 spring.cloud.gateway.routes[3].filters[2].name = Retry spring.cloud.gateway.routes[3].filters[2].args[retries] = 3 spring.cloud.gateway.routes[3].filters[2].args[series] = SERVER_ERROR spring.cloud.gateway.routes[3].filters[2].args[methods] = POST spring.cloud.gateway.routes[3].order = 3

I have the same problem, do you have any solution ?

    <spring-cloud.version>Greenwich.SR2</spring-cloud.version>
walter9088 commented 3 years ago

Through performance measurement, I found that OpenStripPrefixGatewayFilterFactory.Config did not get the correct parts. one hours testing ,This problem was reproduced 5 times. the config in apollo: spring.cloud.gateway.routes[3].id = xxxx spring.cloud.gateway.routes[3].uri = lb://xxx spring.cloud.gateway.routes[3].predicates[0] = Path=/api/userdevice/** spring.cloud.gateway.routes[3].filters[0] = AddRequestHeader=code, META spring.cloud.gateway.routes[3].filters[1] = StripPrefix=2 spring.cloud.gateway.routes[3].filters[2].name = Retry spring.cloud.gateway.routes[3].filters[2].args[retries] = 3 spring.cloud.gateway.routes[3].filters[2].args[series] = SERVER_ERROR spring.cloud.gateway.routes[3].filters[2].args[methods] = POST spring.cloud.gateway.routes[3].order = 3

I have the same problem, do you have any solution ?

    <spring-cloud.version>Greenwich.SR2</spring-cloud.version>

update spring-cloud.version: springboot - 2.2.9.RELEASE springcloud - Hoxton.SR4

spencergibb commented 3 years ago

Can you provide a complete, minimal, verifiable sample that reproduces the problem? It should be available as a GitHub (or similar) project or attached to this issue as a zip file.

spring-cloud-issues commented 3 years ago

If you would like us to look at this issue, please provide the requested information. If the information is not provided within the next 7 days this issue will be closed.

spring-cloud-issues commented 3 years ago

Closing due to lack of requested feedback. If you would like us to look at this issue, please provide the requested information and we will re-open the issue.