[GitHub] [apisix] ShaoZeMing commented on issue #3865: bug: Routing priority matching bug

2021-05-18 Thread GitBox


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
   > 
![图像](https://user-images.githubusercontent.com/6814606/111908745-52de6980-8a95-11eb-9bd1-211aef035309.png)
   
   
   > @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
   > 
![image](https://user-images.githubusercontent.com/6814606/111908745-52de6980-8a95-11eb-9bd1-211aef035309.png)
   
   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:
us...@infra.apache.org




[GitHub] [apisix] ShaoZeMing commented on issue #3865: bug: Routing priority matching bug

2021-03-21 Thread GitBox


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.
   
   
![image](https://user-images.githubusercontent.com/19376576/111907124-ee201080-8a8e-11eb-8be5-02e75fef0d4f.png)
   
   
![image](https://user-images.githubusercontent.com/19376576/111907101-d052ab80-8a8e-11eb-8d16-3f58fc55f2d4.png)
   


-- 
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:
us...@infra.apache.org




[GitHub] [apisix] ShaoZeMing commented on issue #3865: bug: Routing priority matching bug

2021-03-21 Thread GitBox


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

   
![image](https://user-images.githubusercontent.com/19376576/111896275-5bae4b80-8a53-11eb-8ec0-4b9d40338c21.png)
   
   


-- 
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:
us...@infra.apache.org




[GitHub] [apisix] ShaoZeMing commented on issue #3865: bug: Routing priority matching bug

2021-03-20 Thread GitBox


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:
us...@infra.apache.org




[GitHub] [apisix] ShaoZeMing commented on issue #3865: bug: Routing priority matching bug

2021-03-20 Thread GitBox


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:
us...@infra.apache.org




[GitHub] [apisix] ShaoZeMing commented on issue #3865: bug: Routing priority matching bug

2021-03-19 Thread GitBox


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:
us...@infra.apache.org




[GitHub] [apisix] ShaoZeMing commented on issue #3865: bug: Routing priority matching bug

2021-03-19 Thread GitBox


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.
   > 
   > 
![image](https://user-images.githubusercontent.com/2106987/111742029-68e80080-88c2-11eb-9568-7358938518cb.png)
   > 
   > You will notice there has one HTTP call:
   > 
   > 
![image](https://user-images.githubusercontent.com/2106987/111742088-7f8e5780-88c2-11eb-8846-25dd6741a16b.png)
   > 
   > Click it and select `Response` tab:
   > 
   > 
![image](https://user-images.githubusercontent.com/2106987/111742125-8fa63700-88c2-11eb-92d2-8c5c05760cab.png)
   > 
   > Copy this json data here :)
   
   
   okay 
   
![image](https://user-images.githubusercontent.com/19376576/111767907-3a7a1d80-88e2-11eb-81b3-36318e56dd7d.png)
   
   ```
   
{"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:
us...@infra.apache.org




[GitHub] [apisix] ShaoZeMing commented on issue #3865: bug: Routing priority matching bug

2021-03-19 Thread GitBox


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:
us...@infra.apache.org




[GitHub] [apisix] ShaoZeMing commented on issue #3865: bug: Routing priority matching bug

2021-03-18 Thread GitBox


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:
us...@infra.apache.org




[GitHub] [apisix] ShaoZeMing commented on issue #3865: bug: Routing priority matching bug

2021-03-18 Thread GitBox


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": {},
   

[GitHub] [apisix] ShaoZeMing commented on issue #3865: bug: Routing priority matching bug

2021-03-18 Thread GitBox


ShaoZeMing commented on issue #3865:
URL: https://github.com/apache/apisix/issues/3865#issuecomment-801958461


   
![image](https://user-images.githubusercontent.com/19376576/111639611-5d4ef800-8836-11eb-968f-8a7307206e10.png)
   
![image](https://user-images.githubusercontent.com/19376576/111639657-693aba00-8836-11eb-8219-e6b510f6a2f3.png)
   



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:
us...@infra.apache.org