You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@apisix.apache.org by GitBox <gi...@apache.org> on 2021/03/18 14:07:33 UTC
[GitHub] [apisix] ShaoZeMing opened a new issue #3865: bug: Routing priority matching bug
ShaoZeMing opened a new issue #3865:
URL: https://github.com/apache/apisix/issues/3865
### Issue description
### Environment
* apisix version (cmd: `apisix version`): 2.3
* OS (cmd: `uname -a`): centos 7.6
* OpenResty / Nginx version (cmd: `nginx -V` or `openresty -V`): 1.9*
* etcd version, if have (cmd: run `curl http://127.0.0.1:9090/v1/server_info` to get the info from server-info API): 3.4.*
* apisix-dashboard version, if have: 2.4
### Minimal test code / Steps to reproduce the issue
#### I found that the routing matching rules have problems with the matching rules under the same domain name, as shown in the figure

### I prepared 4 routes:
-a: Only `host(test-dev-1.apisix.xthktech.cn)`
-b: `host(test-dev-1.apisix.xthktech.cn)`+`header(app-name:test-header)`
-c: Only `header(app-name=test-header)`
-d: Only `path(/test/*)
The result I got during the visit is like this:
-`host(test-dev-1.apisix.xthktech.cn)` ==> a
-`host(test-dev-1.apisix.xthktech.cn)`+`header(app-name:test-header) ` ==> a
-`header(app-name:test-header) ` ==> c
-`host(test-dev-1.apisix.xthktech.cn)` + `path(/test/*)` ==> a or d (It feels like there is a cache, whoever uses it for the first time, before it expires will not change)
### What's the actual result? (including assertion message & call stack if applicable)
### What's the expected result?
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [apisix] ShaoZeMing commented on issue #3865: bug: Routing priority matching bug
Posted by GitBox <gi...@apache.org>.
ShaoZeMing commented on issue #3865:
URL: https://github.com/apache/apisix/issues/3865#issuecomment-801958461


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [apisix] membphis commented on issue #3865: bug: Routing priority matching bug
Posted by GitBox <gi...@apache.org>.
membphis commented on issue #3865:
URL: https://github.com/apache/apisix/issues/3865#issuecomment-803592575
@ShaoZeMing I listed an example to explain the reason.
Here are three routes(A, B and C), what is their priority?
I think you can talk to me A < B, and A < C, it seems fine.
Between B and C, who has the highest priority? I think it is not easy to reply to this question.
The machine cannot accurately determine who has the higher priority at this time.
```
### router A:only uri
{
"uris":[ "/*" ]
}
### router B :uri + host
{
"uris":["/*"],
"hosts":["test-dev-1.apisix.xthktech.cn"]
}
### router B : uri + header
{
"uris":["/*"],
"vars":[
[
"http_app-name",
"==",
"test-header"
]
]
}
```
In APISIX, when the URI is the same, additional priority needs to be set.
Here is an example, then we know that: B > C > A.
```
router A:only uri
{
"uris":[ "/*" ],
"priority": 0
}
router B :uri + host
{
"uris":["/*"],
"hosts":["test-dev-1.apisix.xthktech.cn"],
"priority": 2
}
router C : uri + header
{
"uris":["/*"],
"vars":[
[
"http_app-name",
"==",
"test-header"
]
],
"priority": 1
}
```
*note*: the default value of `priority` is zero.
https://github.com/apache/apisix/blob/master/docs/en/latest/admin-api.md#route

--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [apisix] Firstsawyou commented on issue #3865: bug: Routing priority matching bug
Posted by GitBox <gi...@apache.org>.
Firstsawyou commented on issue #3865:
URL: https://github.com/apache/apisix/issues/3865#issuecomment-802893821
Hi, @ShaoZeMing
Thank you for your report. After testing, I found that there are problems with the use of `hsot + header` and `host` when different routes have the same uri.
Assuming that the route response data of `host` is `a`, and the route response data of `hsot + header` is `b`, then there are two situations:
1. When the route id of `host` is greater than the route id of `hsot + header`, the result of the request is normal.
2. When the route id of `host` is less than the route id of `hsot + header`, the result of the request is abnormal, and all response data is `a`.
We need to fix this bug.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [apisix] spacewander edited a comment on issue #3865: bug: Routing priority matching bug
Posted by GitBox <gi...@apache.org>.
spacewander edited a comment on issue #3865:
URL: https://github.com/apache/apisix/issues/3865#issuecomment-803232266
The default router (radixtree_uri) is a path first, host second matcher.
If you prefer host first, path second, you can switch to `radixtree_host_uri`:
https://github.com/apache/apisix/blob/1064e2d4b7edcc6f590ca69dc34a100ae6bbc12c/conf/config-default.yaml#L96
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [apisix] tokers commented on issue #3865: bug: Routing priority matching bug
Posted by GitBox <gi...@apache.org>.
tokers commented on issue #3865:
URL: https://github.com/apache/apisix/issues/3865#issuecomment-803555999
@ShaoZeMing In such a case, the priority of the second route rule should be larger than the first one.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [apisix] ShaoZeMing removed a comment on issue #3865: bug: Routing priority matching bug
Posted by GitBox <gi...@apache.org>.
ShaoZeMing removed a comment on issue #3865:
URL: https://github.com/apache/apisix/issues/3865#issuecomment-803517516
> this is not a bug. I confirmed.
>
> @ShaoZeMing the router `a`, `b`, `c` have same uri `/*` and `priority`, you'd better to specify a different `priority`.
>
> `/test/*` always matches before `/*`. The route `radixtree_uri` matching of apisix is depth-first.
如果path 都相同为/*,使用相同的域名 , header 参数匹配规则不一样,但缺走向了 a ,像那个
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [apisix] ShaoZeMing commented on issue #3865: bug: Routing priority matching bug
Posted by GitBox <gi...@apache.org>.
ShaoZeMing commented on issue #3865:
URL: https://github.com/apache/apisix/issues/3865#issuecomment-802571758
> Your configuration data looks strange. It seems that the field names of apisix have been modified?
Sorry i didn't understand you too much
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [apisix] spacewander commented on issue #3865: bug: Routing priority matching bug
Posted by GitBox <gi...@apache.org>.
spacewander commented on issue #3865:
URL: https://github.com/apache/apisix/issues/3865#issuecomment-803871320
Close as it is not a bug.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [apisix] spacewander closed issue #3865: bug: Routing priority matching bug
Posted by GitBox <gi...@apache.org>.
spacewander closed issue #3865:
URL: https://github.com/apache/apisix/issues/3865
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [apisix] Firstsawyou commented on issue #3865: bug: Routing priority matching bug
Posted by GitBox <gi...@apache.org>.
Firstsawyou commented on issue #3865:
URL: https://github.com/apache/apisix/issues/3865#issuecomment-802582617
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [apisix] ShaoZeMing commented on issue #3865: bug: Routing priority matching bug
Posted by GitBox <gi...@apache.org>.
ShaoZeMing commented on issue #3865:
URL: https://github.com/apache/apisix/issues/3865#issuecomment-803583673
> In such a case, the priority of the second route rule should be larger than the first one.
Yes, I think so too, but the actual test is not the case. He always chose the `a` route, which surprised me a bit.


--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [apisix] juzhiyuan commented on issue #3865: bug: Routing priority matching bug
Posted by GitBox <gi...@apache.org>.
juzhiyuan commented on issue #3865:
URL: https://github.com/apache/apisix/issues/3865#issuecomment-802810667
@ShaoZeMing Thanks for your report, that's the data we need. @Firstsawyou will follow and reply to this issue once he finds out what happened.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [apisix] ShaoZeMing commented on issue #3865: bug: Routing priority matching bug
Posted by GitBox <gi...@apache.org>.
ShaoZeMing commented on issue #3865:
URL: https://github.com/apache/apisix/issues/3865#issuecomment-802732450
Hi, Here are the routing rules a, b, c, d
router a:
```
{
"code":0,
"message":"",
"data":{
"id":"346524199914832835",
"create_time":1616074118,
"update_time":1616118098,
"uris":[
"/*"
],
"name":"test_host",
"desc":"测试仅只有host",
"methods":[
"GET"
],
"hosts":[
"test-dev-1.apisix.xthktech.cn"
],
"vars":[
],
"plugins":{
"jwt-auth":{
"disable":false
}
},
"upstream_id":"341144078647297023",
"labels":{
"API_VERSION":"v0.0.1"
},
"status":1
},
"request_id":"3db8e16d-0346-4066-9dc9-e81a64d2a750"
}
```
- router b :
```
{
"code":0,
"message":"",
"data":{
"id":"346524374901195715",
"create_time":1616074222,
"update_time":1616118115,
"uris":[
"/*"
],
"name":"test_host_header",
"desc":"测试同时有host+header(app-name:test-header)",
"methods":[
"GET"
],
"hosts":[
"test-dev-1.apisix.xthktech.cn"
],
"vars":[
[
"http_app-name",
"==",
"test-header"
]
],
"plugins":{
"hmac-auth":{
"disable":false
}
},
"upstream_id":"341144078647297023",
"labels":{
"API_VERSION":"v0.0.1"
},
"status":1
},
"request_id":"c1e232c2-2aa3-4da9-abd0-34a3191c31d9"
}
```
- router c :
```
{
"code":0,
"message":"",
"data":{
"id":"346525280149439427",
"create_time":1616074762,
"update_time":1616118134,
"uris":[
"/*"
],
"name":"test_header",
"desc":"测试只有header(app-name:test-header) ",
"methods":[
"GET"
],
"vars":[
[
"http_app-name",
"==",
"test-header"
]
],
"plugins":{
"key-auth":{
"disable":false
}
},
"upstream_id":"341144078647297023",
"labels":{
"API_VERSION":"v0.0.1"
},
"status":1
},
"request_id":"f0f019f4-9edb-4457-8e66-ec4feba5aec0"
}
```
- router d :
```
{
"code":0,
"message":"",
"data":{
"id":"346598189450658703",
"create_time":1616118219,
"update_time":1616118237,
"uris":[
"/test/*"
],
"name":"test_path",
"methods":[
"GET"
],
"vars":[
],
"plugins":{
"basic-auth":{
"disable":false
}
},
"upstream_id":"341144078647297023",
"status":1
},
"request_id":"5c2fbd70-0846-47fc-9e81-b3e94373c27c"
}
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [apisix] ShaoZeMing commented on issue #3865: bug: Routing priority matching bug
Posted by GitBox <gi...@apache.org>.
ShaoZeMing commented on issue #3865:
URL: https://github.com/apache/apisix/issues/3865#issuecomment-803517516
> this is not a bug. I confirmed.
>
> @ShaoZeMing the router `a`, `b`, `c` have same uri `/*` and `priority`, you'd better to specify a different `priority`.
>
> `/test/*` always matches before `/*`. The route `radixtree_uri` matching of apisix is depth-first.
如果path 都相同为/*,使用相同的域名 , header 参数匹配规则不一样,但缺走向了 a ,像那个
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [apisix] spacewander commented on issue #3865: bug: Routing priority matching bug
Posted by GitBox <gi...@apache.org>.
spacewander commented on issue #3865:
URL: https://github.com/apache/apisix/issues/3865#issuecomment-803232266
The default router (radixtree_uri) is a path first, host second matcher.
If you prefer a host first, path second, you can switch to `radixtree_host_uri`:
https://github.com/apache/apisix/blob/1064e2d4b7edcc6f590ca69dc34a100ae6bbc12c/conf/config-default.yaml#L96
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [apisix] Firstsawyou edited a comment on issue #3865: bug: Routing priority matching bug
Posted by GitBox <gi...@apache.org>.
Firstsawyou edited a comment on issue #3865:
URL: https://github.com/apache/apisix/issues/3865#issuecomment-802893821
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [apisix] ShaoZeMing commented on issue #3865: bug: Routing priority matching bug
Posted by GitBox <gi...@apache.org>.
ShaoZeMing commented on issue #3865:
URL: https://github.com/apache/apisix/issues/3865#issuecomment-842992553
> @ShaoZeMing我列出了一个示例来解释原因。
>
> 这里有三条路线(`A`,`B`和`C`),什么是他们的优先级?
> 我认为您可以和我`A`<`B`和`A`<交谈`C`,这似乎很好。
>
> 在`B`和之间`C`,谁的优先级最高?我认为要回答这个问题并不容易。
> 机器此时无法准确确定谁的优先级更高。
>
> ```
> ### router A:only uri
> {
> "uris":[ "/*" ]
> }
>
> ### router B :uri + host
> {
> "uris":["/*"],
> "hosts":["test-dev-1.apisix.xthktech.cn"]
> }
>
> ### router B : uri + header
> {
> "uris":["/*"],
> "vars":[
> [
> "http_app-name",
> "==",
> "test-header"
> ]
> ]
> }
> ```
>
> 在APISIX中,当URI相同时,需要设置其他优先级。
> 这是一个示例,然后我们知道:B> C> A。
>
> ```
> router A:only uri
> {
> "uris":[ "/*" ],
> "priority": 0
> }
>
> router B :uri + host
> {
> "uris":["/*"],
> "hosts":["test-dev-1.apisix.xthktech.cn"],
> "priority": 2
> }
>
> router C : uri + header
> {
> "uris":["/*"],
> "vars":[
> [
> "http_app-name",
> "==",
> "test-header"
> ]
> ],
> "priority": 1
> }
> ```
>
> _注意_:的`priority`最大值零。
>
> https://github.com/apache/apisix/blob/master/docs/en/latest/admin-api.md#route
> 
> @ShaoZeMing I listed an example to explain the reason.
>
> Here are three routes(`A`, `B` and `C`), what is their priority?
> I think you can talk to me `A` < `B`, and `A` < `C`, it seems fine.
>
> Between `B` and `C`, who has the highest priority? I think it is not easy to reply to this question.
> The machine cannot accurately determine who has the higher priority at this time.
>
> ```
> ### router A:only uri
> {
> "uris":[ "/*" ]
> }
>
> ### router B :uri + host
> {
> "uris":["/*"],
> "hosts":["test-dev-1.apisix.xthktech.cn"]
> }
>
> ### router B : uri + header
> {
> "uris":["/*"],
> "vars":[
> [
> "http_app-name",
> "==",
> "test-header"
> ]
> ]
> }
> ```
>
> In APISIX, when the URI is the same, additional priority needs to be set.
> Here is an example, then we know that: B > C > A.
>
> ```
> router A:only uri
> {
> "uris":[ "/*" ],
> "priority": 0
> }
>
> router B :uri + host
> {
> "uris":["/*"],
> "hosts":["test-dev-1.apisix.xthktech.cn"],
> "priority": 2
> }
>
> router C : uri + header
> {
> "uris":["/*"],
> "vars":[
> [
> "http_app-name",
> "==",
> "test-header"
> ]
> ],
> "priority": 1
> }
> ```
>
> _note_: the default value of `priority` is zero.
>
> https://github.com/apache/apisix/blob/master/docs/en/latest/admin-api.md#route
> 
Sorry, I'm here to bother you again. I did configure A and B according to the method in this document, but did not achieve the effect of B>A;
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [apisix] Firstsawyou commented on issue #3865: bug: Routing priority matching bug
Posted by GitBox <gi...@apache.org>.
Firstsawyou commented on issue #3865:
URL: https://github.com/apache/apisix/issues/3865#issuecomment-802634629
> @Firstsawyou
>
> [#3865 (comment)](https://github.com/apache/apisix/issues/3865#issuecomment-802452402) is exported as `OpenAPI v3`.
okay.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [apisix] ShaoZeMing edited a comment on issue #3865: bug: Routing priority matching bug
Posted by GitBox <gi...@apache.org>.
ShaoZeMing edited a comment on issue #3865:
URL: https://github.com/apache/apisix/issues/3865#issuecomment-803583673
> In such a case, the priority of the second route rule should be larger than the first one.
Yes, I think so too, but the actual test is not the case. He always chose the `a` route, which surprised me a bit.


```
router a:
{
"code":0,
"message":"",
"data":{
"id":"346524199914832835",
"create_time":1616074118,
"update_time":1616118098,
"uris":[
"/*"
],
"name":"test_host",
"desc":"测试仅只有host",
"methods":[
"GET"
],
"hosts":[
"test-dev-1.apisix.xthktech.cn"
],
"vars":[
],
"plugins":{
"jwt-auth":{
"disable":false
}
},
"upstream_id":"341144078647297023",
"labels":{
"API_VERSION":"v0.0.1"
},
"status":1
},
"request_id":"3db8e16d-0346-4066-9dc9-e81a64d2a750"
}
router b :
{
"code":0,
"message":"",
"data":{
"id":"346524374901195715",
"create_time":1616074222,
"update_time":1616118115,
"uris":[
"/*"
],
"name":"test_host_header",
"desc":"测试同时有host+header(app-name:test-header)",
"methods":[
"GET"
],
"hosts":[
"test-dev-1.apisix.xthktech.cn"
],
"vars":[
[
"http_app-name",
"==",
"test-header"
]
],
"plugins":{
"hmac-auth":{
"disable":false
}
},
"upstream_id":"341144078647297023",
"labels":{
"API_VERSION":"v0.0.1"
},
"status":1
},
"request_id":"c1e232c2-2aa3-4da9-abd0-34a3191c31d9"
}
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [apisix] Firstsawyou commented on issue #3865: bug: Routing priority matching bug
Posted by GitBox <gi...@apache.org>.
Firstsawyou commented on issue #3865:
URL: https://github.com/apache/apisix/issues/3865#issuecomment-802756878
> Hi, Here are the routing rules a, b, c, d
@ShaoZeMing Thank you for the information, I will reproduce it later.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [apisix] ShaoZeMing commented on issue #3865: bug: Routing priority matching bug
Posted by GitBox <gi...@apache.org>.
ShaoZeMing commented on issue #3865:
URL: https://github.com/apache/apisix/issues/3865#issuecomment-802589320
> > > Your configuration data looks strange. It seems that the field names of apisix have been modified?
> >
> >
> > Sorry i didn't understand you too much
>
> There are many "x-apisix-xxx" field names in your configuration, which are not "x-apisix" in APISIX, for example: "x-apisix-vars", it should be "vars" in APISIX .
I haven't configured this extra, what I used is the simplest configuration, which should come with the program, and my configuration is exported through the console.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [apisix] spacewander commented on issue #3865: bug: Routing priority matching bug
Posted by GitBox <gi...@apache.org>.
spacewander commented on issue #3865:
URL: https://github.com/apache/apisix/issues/3865#issuecomment-803521001
>
>
> > this is not a bug. I confirmed.
> > @ShaoZeMing the router `a`, `b`, `c` have same uri `/*` and `priority`, you'd better to specify a different `priority`.
> > `/test/*` always matches before `/*`. The route `radixtree_uri` matching of apisix is depth-first.
>
> If the path is the same as /* and the same domain name is used, the header parameter matching rules are different, but the missing direction is a, such as this:
> -host(test-dev-1.apisix.xthktech.cn) ==> a
> -host(test-dev-1.apisix.xthktech.cn)+header(app-name:test-header) ==> a
Excuse me. I can't understand what you mean.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [apisix] ShaoZeMing commented on issue #3865: bug: Routing priority matching bug
Posted by GitBox <gi...@apache.org>.
ShaoZeMing commented on issue #3865:
URL: https://github.com/apache/apisix/issues/3865#issuecomment-802728346
> @ShaoZeMing Hi, thanks for your report, let's try to resolve your issue. And please try the following steps:
>
> In dashboard 2.4, we don't support showing route configuration (JSON format) directly, now please open the `Network` panel in `Chrome`, and click the `Edit` button.
>
> 
>
> You will notice there has one HTTP call:
>
> 
>
> Click it and select `Response` tab:
>
> 
>
> Copy this json data here :)
okay

```
{"code":0,"message":"","data":{"id":"346524374901195715","create_time":1616074222,"update_time":1616118115,"uris":["/*"],"name":"test_host_header","desc":"测试同时有host+header(app-name:test-header)","methods":["GET"],"hosts":["test-dev-1.apisix.xthktech.cn"],"vars":[["http_app-name","==","test-header"]],"plugins":{"hmac-auth":{"disable":false}},"upstream_id":"341144078647297023","labels":{"API_VERSION":"v0.0.1"},"status":1},"request_id":"0df57ac8-4d86-433a-bd4c-0c4f5b1a5a5a"}
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [apisix] ShaoZeMing commented on issue #3865: bug: Routing priority matching bug
Posted by GitBox <gi...@apache.org>.
ShaoZeMing commented on issue #3865:
URL: https://github.com/apache/apisix/issues/3865#issuecomment-803517605
> this is not a bug. I confirmed.
>
> @ShaoZeMing the router `a`, `b`, `c` have same uri `/*` and `priority`, you'd better to specify a different `priority`.
>
> `/test/*` always matches before `/*`. The route `radixtree_uri` matching of apisix is depth-first.
If the path is the same as /* and the same domain name is used, the header parameter matching rules are different, but the missing direction is a, such as this:
-host(test-dev-1.apisix.xthktech.cn) ==> a
-host(test-dev-1.apisix.xthktech.cn)+header(app-name:test-header) ==> a
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [apisix] membphis edited a comment on issue #3865: bug: Routing priority matching bug
Posted by GitBox <gi...@apache.org>.
membphis edited a comment on issue #3865:
URL: https://github.com/apache/apisix/issues/3865#issuecomment-803592575
@ShaoZeMing I listed an example to explain the reason.
Here are three routes(`A`, `B` and `C`), what is their priority?
I think you can talk to me `A` < `B`, and `A` < `C`, it seems fine.
Between `B` and `C`, who has the highest priority? I think it is not easy to reply to this question.
The machine cannot accurately determine who has the higher priority at this time.
```
### router A:only uri
{
"uris":[ "/*" ]
}
### router B :uri + host
{
"uris":["/*"],
"hosts":["test-dev-1.apisix.xthktech.cn"]
}
### router B : uri + header
{
"uris":["/*"],
"vars":[
[
"http_app-name",
"==",
"test-header"
]
]
}
```
In APISIX, when the URI is the same, additional priority needs to be set.
Here is an example, then we know that: B > C > A.
```
router A:only uri
{
"uris":[ "/*" ],
"priority": 0
}
router B :uri + host
{
"uris":["/*"],
"hosts":["test-dev-1.apisix.xthktech.cn"],
"priority": 2
}
router C : uri + header
{
"uris":["/*"],
"vars":[
[
"http_app-name",
"==",
"test-header"
]
],
"priority": 1
}
```
*note*: the default value of `priority` is zero.
https://github.com/apache/apisix/blob/master/docs/en/latest/admin-api.md#route

--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [apisix] membphis commented on issue #3865: bug: Routing priority matching bug
Posted by GitBox <gi...@apache.org>.
membphis commented on issue #3865:
URL: https://github.com/apache/apisix/issues/3865#issuecomment-803225177
this is not a bug. I confirmed.
@ShaoZeMing the router `a`, `b`, `c` have same uri `/*` and `priority`, you'd better to specify a different `priority`.
`/test/*` always matches before `/*`. The route `radixtree_uri` matching of apisix is depth-first.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [apisix] Firstsawyou commented on issue #3865: bug: Routing priority matching bug
Posted by GitBox <gi...@apache.org>.
Firstsawyou commented on issue #3865:
URL: https://github.com/apache/apisix/issues/3865#issuecomment-802524955
Your configuration data looks strange. It seems that the field names of apisix have been modified?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [apisix] moonming commented on issue #3865: bug: Routing priority matching bug
Posted by GitBox <gi...@apache.org>.
moonming commented on issue #3865:
URL: https://github.com/apache/apisix/issues/3865#issuecomment-803185212
@membphis @spacewander please take a look
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [apisix] Firstsawyou removed a comment on issue #3865: bug: Routing priority matching bug
Posted by GitBox <gi...@apache.org>.
Firstsawyou removed a comment on issue #3865:
URL: https://github.com/apache/apisix/issues/3865#issuecomment-802582618
> > Your configuration data looks strange. It seems that the field names of apisix have been modified?
>
> Sorry i didn't understand you too much
There are many "x-apisix-xxx" field names in your configuration, which are not "x-apisix" in APISIX, for example: "x-apisix-vars", it should be "vars" in APISIX .
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [apisix] juzhiyuan commented on issue #3865: bug: Routing priority matching bug
Posted by GitBox <gi...@apache.org>.
juzhiyuan commented on issue #3865:
URL: https://github.com/apache/apisix/issues/3865#issuecomment-802600363
@Firstsawyou
https://github.com/apache/apisix/issues/3865#issuecomment-802452402 is exported as `OpenAPI v3`.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [apisix] juzhiyuan commented on issue #3865: bug: Routing priority matching bug
Posted by GitBox <gi...@apache.org>.
juzhiyuan commented on issue #3865:
URL: https://github.com/apache/apisix/issues/3865#issuecomment-802599858
@ShaoZeMing Hi, thanks for your report, let's try to resolve your issue. And please try the following steps:
In dashboard 2.4, we don't support showing route configuration (JSON format) directly, now please open the `Network` panel in `Chrome`, and click the `Edit` button.

You will notice there has one HTTP call:

Click it and select `Response` tab:

Copy this json data here :)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [apisix] spacewander commented on issue #3865: bug: Routing priority matching bug
Posted by GitBox <gi...@apache.org>.
spacewander commented on issue #3865:
URL: https://github.com/apache/apisix/issues/3865#issuecomment-803578344
The order of matching is like this:
1. match path?
2. check each matched rule, order by priority
3. check host
4. check other conditions
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [apisix] Firstsawyou commented on issue #3865: bug: Routing priority matching bug
Posted by GitBox <gi...@apache.org>.
Firstsawyou commented on issue #3865:
URL: https://github.com/apache/apisix/issues/3865#issuecomment-802439584
You should provide more detailed route configuration information.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [apisix] ShaoZeMing commented on issue #3865: bug: Routing priority matching bug
Posted by GitBox <gi...@apache.org>.
ShaoZeMing commented on issue #3865:
URL: https://github.com/apache/apisix/issues/3865#issuecomment-802452402
> You should provide more detailed route configuration information.
```
{
"components": {
"securitySchemes": {
"api_key": {
"in": "header",
"name": "X-XSRF-TOKEN",
"type": "apiKey"
},
"basicAuth": {
"in": "header",
"name": "basicAuth",
"type": "basicAuth"
},
"bearerAuth": {
"bearerFormat": "JWT",
"scheme": "bearer",
"type": "http"
}
}
},
"info": {
"title": "RoutesExport",
"version": "3.0.0"
},
"openapi": "3.0.0",
"paths": {
"/test/{params}": {
"get": {
"operationId": "test_pathGET",
"parameters": [{
"description": "params in path",
"in": "path",
"name": "params",
"required": true,
"schema": {
"type": "string"
}
}, {
"description": "params in path",
"in": "path",
"name": "params",
"required": true,
"schema": {
"type": "string"
}
}, {
"description": "params in path",
"in": "path",
"name": "params",
"required": true,
"schema": {
"type": "string"
}
}, {
"description": "params in path",
"in": "path",
"name": "params",
"required": true,
"schema": {
"type": "string"
}
}],
"requestBody": {},
"responses": {
"default": {
"description": ""
}
},
"security": [{
"basicAuth": [" "]
}],
"x-apisix-enable_websocket": false,
"x-apisix-plugins": {},
"x-apisix-priority": 0,
"x-apisix-status": 1,
"x-apisix-upstream": {
"id": "341144078647297023",
"create_time": 1612867316,
"update_time": 1614741356,
"nodes": [{
"host": "xthy-sso-api-pub",
"port": 80,
"weight": 1
}],
"timeout": {
"connect": 6000,
"read": 6000,
"send": 6000
},
"type": "roundrobin",
"pass_host": "rewrite",
"upstream_host": "xthy-sso-api-pub",
"name": "花园认证服务",
"desc": "花园认证服务"
},
"x-apisix-vars": []
}
},
"/{params}": {
"get": {
"operationId": "test_hostGET",
"parameters": [{
"description": "params in path",
"in": "path",
"name": "params",
"required": true,
"schema": {
"type": "string"
}
}],
"requestBody": {},
"responses": {
"default": {
"description": ""
}
},
"security": [{
"bearerAuth": [" "]
}],
"summary": "测试仅只有host",
"x-apisix-enable_websocket": false,
"x-apisix-hosts": ["test-dev-1.apisix.xthktech.cn"],
"x-apisix-labels": {
"API_VERSION": "v0.0.1"
},
"x-apisix-plugins": {},
"x-apisix-priority": 0,
"x-apisix-status": 1,
"x-apisix-upstream": {
"id": "341144078647297023",
"create_time": 1612867316,
"update_time": 1614741356,
"nodes": [{
"host": "xthy-sso-api-pub",
"port": 80,
"weight": 1
}],
"timeout": {
"connect": 6000,
"read": 6000,
"send": 6000
},
"type": "roundrobin",
"pass_host": "rewrite",
"upstream_host": "xthy-sso-api-pub",
"name": "花园认证服务",
"desc": "花园认证服务"
},
"x-apisix-vars": []
}
},
"/{params}-APISIX-REPEAT-URI-2": {
"get": {
"operationId": "test_host_headerGET",
"parameters": [{
"description": "params in path",
"in": "path",
"name": "params",
"required": true,
"schema": {
"type": "string"
}
}, {
"description": "params in path",
"in": "path",
"name": "params",
"required": true,
"schema": {
"type": "string"
}
}],
"requestBody": {},
"responses": {
"default": {
"description": ""
}
},
"security": [],
"summary": "测试同时有host+header(app-name:test-header)",
"x-apisix-enable_websocket": false,
"x-apisix-hosts": ["test-dev-1.apisix.xthktech.cn"],
"x-apisix-labels": {
"API_VERSION": "v0.0.1"
},
"x-apisix-plugins": {
"hmac-auth": {
"disable": false
}
},
"x-apisix-priority": 0,
"x-apisix-status": 1,
"x-apisix-upstream": {
"id": "341144078647297023",
"create_time": 1612867316,
"update_time": 1614741356,
"nodes": [{
"host": "xthy-sso-api-pub",
"port": 80,
"weight": 1
}],
"timeout": {
"connect": 6000,
"read": 6000,
"send": 6000
},
"type": "roundrobin",
"pass_host": "rewrite",
"upstream_host": "xthy-sso-api-pub",
"name": "花园认证服务",
"desc": "花园认证服务"
},
"x-apisix-vars": [
["http_app-name", "==", "test-header"]
]
}
},
"/{params}-APISIX-REPEAT-URI-3": {
"get": {
"operationId": "test_headerGET",
"parameters": [{
"description": "params in path",
"in": "path",
"name": "params",
"required": true,
"schema": {
"type": "string"
}
}, {
"description": "params in path",
"in": "path",
"name": "params",
"required": true,
"schema": {
"type": "string"
}
}, {
"description": "params in path",
"in": "path",
"name": "params",
"required": true,
"schema": {
"type": "string"
}
}],
"requestBody": {},
"responses": {
"default": {
"description": ""
}
},
"security": [{
"api_key": [" "]
}],
"summary": "测试只有header(app-name:test-header) ",
"x-apisix-enable_websocket": false,
"x-apisix-labels": {
"API_VERSION": "v0.0.1"
},
"x-apisix-plugins": {},
"x-apisix-priority": 0,
"x-apisix-status": 1,
"x-apisix-upstream": {
"id": "341144078647297023",
"create_time": 1612867316,
"update_time": 1614741356,
"nodes": [{
"host": "xthy-sso-api-pub",
"port": 80,
"weight": 1
}],
"timeout": {
"connect": 6000,
"read": 6000,
"send": 6000
},
"type": "roundrobin",
"pass_host": "rewrite",
"upstream_host": "xthy-sso-api-pub",
"name": "花园认证服务",
"desc": "花园认证服务"
},
"x-apisix-vars": [
["http_app-name", "==", "test-header"]
]
}
}
}
}
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [apisix] ShaoZeMing commented on issue #3865: bug: Routing priority matching bug
Posted by GitBox <gi...@apache.org>.
ShaoZeMing commented on issue #3865:
URL: https://github.com/apache/apisix/issues/3865#issuecomment-803521618
> If the path is the same as /* and the same domain name is used, the header parameter matching rules are different, but the missing direction is a, such as this:
> -host(test-dev-1.apisix.xthktech.cn) ==> a
> -host(test-dev-1.apisix.xthktech.cn)+header(app-name:test-header) ==> a
As shown, I use a unified domain name. I want to match different routing rules based on the requested header parameter value, but the result is like this. Is this reasonable? Is it a `or` relationship?
- host(test-dev-1.apisix.xthktech.cn) ==> a
- host(test-dev-1.apisix.xthktech.cn)+header(app-name:test-header) ==> a

--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org