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.5k stars 3.31k forks source link

When configuring rules, if the custom configuration path and the service name are the same, the custom configuration is not used #2012

Open beiluonever opened 3 years ago

beiluonever commented 3 years ago

Describe the bug Spring Cloud version : Hoxton.SR8 Spring Boot version : 2.2.6.RELEASE

This bug like that Condition 1:I have one service register to Consul with name eg. serviceName, this service ip port is 172,0.0.1:9090 Condition 2: I add one route eg.

I hope gateway using my custom configuration, bypass my request to ws://172,0.0.1:8080,but in fact ,gateway distribution request to 172,0.0.1:9090

Reading the source code, the system will use the servicename of the same registry as the default rule, and when all the rules are obtained, the first suitable one will be forwarded. I don’t have a more suitable way to modify, so I asked this question.

If you have different opinions on this issue, please let me know. Or tell me your repair method, I can try to help implement it

spencergibb commented 3 years ago

Do you want automated route configuration from discovery?

beiluonever commented 3 years ago

Do you want automated route configuration from discovery?

It may be needed sometimes, is there a switch to control it? I am more concerned about what the gateway will do when the two conflicts.

spencergibb commented 3 years ago

try setting the order attribute on the conflicting route.

beiluonever commented 3 years ago

try setting the order attribute on the conflicting route.

Yes, I know the order configuration. But I raised this issue to know if the conflicting configuration I mentioned is a bug and whether there are plans to fix it.

spencergibb commented 3 years ago

I don't believe it is.

beiluonever commented 3 years ago

I don't believe it is.

Okay, I will take the time to build a minimal project to test this issue. thank you for your reply

beiluonever commented 3 years ago

https://github.com/beiluonever/spring-gateway-issue-2012 This is the demo I tested,I hope it helps

beiluonever commented 3 years ago

@spencergibb hi,Could you please take a moment to reply