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 2020/12/27 07:27:09 UTC
[GitHub] [apisix] zhuliquan opened a new issue #3134: I have some trouble on route match
zhuliquan opened a new issue #3134:
URL: https://github.com/apache/apisix/issues/3134
### Issue description
I set two routes like this:
##route1
{"uris":["/test/v1/files/*"],"name":"get_file1","desc":"get_file1","methods":["GET"],"vars":[],"plugins":{"proxy-rewrite":{"regex_uri":["^/test/v1/files/(.+)","/v1/files/$1"]}},"upstream_id":"333773215308464216"}
##route2
{"uris":["/test/v1/files:listReputationHistories"],"name":"list_reputation_history1","methods":["POST"],"vars":[],"plugins":{"proxy-rewrite":{"uri":"/v1/files:listReputationHistories"}},"upstream_id":"333773215308464216"}
But run command: `curl "http://127.0.0.1:9080/test/v1/files:xxxdsadsadxxx" -XPOST -d {"uri":"xxx"}` , It also can return results.
APISIX sames to match '/test/v1/files:xxxdsadsadxxx' to '"/test/v1/files:listReputationHistories'. I also try other cases: `curl "http://127.0.0.1:9080/test/v1/files: {any string}" -XPOST -d {"uri":"xxx"}` , APISIX sames ignore string behind ':'.
### Environment
* apisix version (cmd: `2.1`):
----------------------------------------------------------------
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 #3134: I have some trouble on route match
Posted by GitBox <gi...@apache.org>.
spacewander commented on issue #3134:
URL: https://github.com/apache/apisix/issues/3134#issuecomment-751729906
We need to fix it in lua-resty-radixtree. ":" is legal in uri and is recommended in RESTful API by Google: https://cloud.google.com/apis/design/custom_methods
----------------------------------------------------------------
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 #3134: I have some trouble on route match
Posted by GitBox <gi...@apache.org>.
tokers commented on issue #3134:
URL: https://github.com/apache/apisix/issues/3134#issuecomment-751713265
See https://github.com/api7/lua-resty-radixtree#parameters-in-path, `:` in the Route of APISIX has special meanings.
----------------------------------------------------------------
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 closed issue #3134: I have some trouble on route match
Posted by GitBox <gi...@apache.org>.
membphis closed issue #3134:
URL: https://github.com/apache/apisix/issues/3134
----------------------------------------------------------------
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] zhuliquan edited a comment on issue #3134: I have some trouble on route match
Posted by GitBox <gi...@apache.org>.
zhuliquan edited a comment on issue #3134:
URL: https://github.com/apache/apisix/issues/3134#issuecomment-751463366
# GRPC service
I use grpc build service
protobuf:
```syntax="proto3";
import "google/api/annotations.proto";
package test_grpc.api.file;
option go_package = ".;file";
message Request {
string uri = 1;
}
message Response {
string info = 1;
}
service File {
rpc GetFile (Request) returns (Response) {
option (google.api.http) = {
get: "/v1/{uri=files/*}"
};
}
rpc ListReputationHistories (Request) returns (Response) {
option (google.api.http) = {
post: "/v1/files:listReputationHistories"
};
}
}
```
service code.
```
func (s *FileServerImpl) GetFile(ctx context.Context, r *file.Request) (*file.Response, error) {
return &file.Response{Info: "GetFile:" + r.GetUri()}, nil
}
func (s *FileServerImpl) ListReputationHistories(ctx context.Context, r *file.Request) (*file.Response, error) {
return &file.Response{Info: "ListReputationHistories:" + r.GetUri()}, nil
}
```
I run service with prot:9201 .
# APISIX
upstreams:
```
curl -XPUT "http://127.0.0.1:9080/apisix/admin/upstreams/1" -H 'X-API-KEY: edd1c9f034335f136f87ad84b625c8f1' -d '{"nodes":{"host":"127.0.0.1:9201" : 1}, "type":"roundrobin", "name":"test_grpc_http"}'
```
routes:
```
curl -XPUT "http://127.0.0.1:9080/apisix/admin/routes/1" -H 'X-API-KEY: edd1c9f034335f136f87ad84b625c8f1' -d '{"uris":["/test/v1/files/*"],"name":"get_file1","methods":["GET"],"plugins":{"proxy-rewrite":{"regex_uri":["^/test/v1/files/(.+)","/v1/files/$1"]}},"upstream_id":"1"}'
curl -XPUT "http://127.0.0.1:9080/apisix/admin/routes/2" -H 'X-API-KEY: edd1c9f034335f136f87ad84b625c8f1' -d '{"uris":["/test/v1/files:listReputationHistories"],"name":"list_reputation_history1","methods":["POST"],"plugins":{"proxy-rewrite":{"uri":"/v1/files:listReputationHistories"}},"upstream_id":"1"}'
```
#Fact
I send any post request with prefix ---/test/v1/files:--- , result is same with ---/test/v1/files:listReputationHistories---
for example:
curl "http://127.0.0.1:9080/test/v1/files:esxxx" -XPOST -d {"uri":"xxx"}
{"info":"ListReputationHistories:"}(base)
`
----------------------------------------------------------------
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] zhuliquan edited a comment on issue #3134: I have some trouble on route match
Posted by GitBox <gi...@apache.org>.
zhuliquan edited a comment on issue #3134:
URL: https://github.com/apache/apisix/issues/3134#issuecomment-751544555
> The characters with `:` in the `url` here are very similar to the prefix path, right? @spacewander
Yes, **/test/v1/files:/test/v1/files:listReputationHistories** and **/test/v1/files:xxxxxxx** will return same results, even I don't define route with **/test/v1/files:xxxxxxx**. APISIX ignore characters behind **':'** , only match character before **':'**
----------------------------------------------------------------
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] zhuliquan edited a comment on issue #3134: I have some trouble on route match
Posted by GitBox <gi...@apache.org>.
zhuliquan edited a comment on issue #3134:
URL: https://github.com/apache/apisix/issues/3134#issuecomment-751463366
# GRPC service
I use grpc build service
protobuf:
```syntax="proto3";
import "google/api/annotations.proto";
package test_grpc.api.file;
option go_package = ".;file";
message Request {
string uri = 1;
}
message Response {
string info = 1;
}
service File {
rpc GetFile (Request) returns (Response) {
option (google.api.http) = {
get: "/v1/{uri=files/*}"
};
}
rpc ListReputationHistories (Request) returns (Response) {
option (google.api.http) = {
post: "/v1/files:listReputationHistories"
};
}
}
```
service code.
```
func (s *FileServerImpl) GetFile(ctx context.Context, r *file.Request) (*file.Response, error) {
return &file.Response{Info: "GetFile:" + r.GetUri()}, nil
}
func (s *FileServerImpl) ListReputationHistories(ctx context.Context, r *file.Request) (*file.Response, error) {
return &file.Response{Info: "ListReputationHistories:" + r.GetUri()}, nil
}
```
I run service with prot:9201 .
# APISIX
upstreams:
```
curl -XPUT "http://127.0.0.1:9080/apisix/admin/upstreams/1" -H 'X-API-KEY: edd1c9f034335f136f87ad84b625c8f1' -d '{"nodes":{"host":"127.0.0.1:9201" : 1}, "type":"roundrobin", "name":"test_grpc_http"}'
```
routes:
```
curl -XPUT "http://127.0.0.1:9080/apisix/admin/routes/1" -H 'X-API-KEY: edd1c9f034335f136f87ad84b625c8f1' -d '{"uris":["/test/v1/files/*"],"name":"get_file1","methods":["GET"],"plugins":{"proxy-rewrite":{"regex_uri":["^/test/v1/files/(.+)","/v1/files/$1"]}},"upstream_id":"1"}'
curl -XPUT "http://127.0.0.1:9080/apisix/admin/routes/2" -H 'X-API-KEY: edd1c9f034335f136f87ad84b625c8f1' -d '{"uris":["/test/v1/files:listReputationHistories"],"name":"list_reputation_history1","methods":["POST"],"plugins":{"proxy-rewrite":{"uri":"/v1/files:listReputationHistories"}},"upstream_id":"1"}'
```
# Fact
I send any post request with prefix **/test/v1/files:** , result is same with **/test/v1/files:listReputationHistories**
for example:
curl "http://127.0.0.1:9080/test/v1/files:esxxx" -XPOST -d {"uri":"xxx"}
{"info":"ListReputationHistories:"}(base)

`
----------------------------------------------------------------
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] zhuliquan commented on issue #3134: I have some trouble on route match
Posted by GitBox <gi...@apache.org>.
zhuliquan commented on issue #3134:
URL: https://github.com/apache/apisix/issues/3134#issuecomment-751544555
> The characters with `:` in the `url` here are very similar to the prefix path, right? @spacewander
No, **/test/v1/files:/test/v1/files:listReputationHistories** and **/test/v1/files:xxxxxxx** will return same results, even I don't define route with **/test/v1/files:xxxxxxx**. APISIX ignore characters behind **':'** , only match character before **':'**
----------------------------------------------------------------
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 #3134: I have some trouble on route match
Posted by GitBox <gi...@apache.org>.
Firstsawyou commented on issue #3134:
URL: https://github.com/apache/apisix/issues/3134#issuecomment-751458508
Can you provide a minimal reproducible use case?
----------------------------------------------------------------
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 #3134: I have some trouble on route match
Posted by GitBox <gi...@apache.org>.
Firstsawyou commented on issue #3134:
URL: https://github.com/apache/apisix/issues/3134#issuecomment-751487805
The characters with `:` in the `url` here are very similar to the prefix path, right? @spacewander
----------------------------------------------------------------
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] zhuliquan removed a comment on issue #3134: I have some trouble on route match
Posted by GitBox <gi...@apache.org>.
zhuliquan removed a comment on issue #3134:
URL: https://github.com/apache/apisix/issues/3134#issuecomment-751463800
I have post my case in issue #3134发自我的华为手机-------- 原始邮件 --------发件人: Yuelin Zheng <no...@github.com>日期: 2020年12月27日周日 19:53收件人: apache/apisix <ap...@noreply.github.com>抄送: zhuliquan <zl...@sina.com>, Author <au...@noreply.github.com>主 题: Re: [apache/apisix] I have some trouble on route match (#3134)
Can you provide a minimal reproducible use case?
—You are receiving this because you authored the thread.Reply to this email directly, view it on GitHub, or unsubscribe.
----------------------------------------------------------------
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] zhuliquan edited a comment on issue #3134: I have some trouble on route match
Posted by GitBox <gi...@apache.org>.
zhuliquan edited a comment on issue #3134:
URL: https://github.com/apache/apisix/issues/3134#issuecomment-751463366
# GRPC service
I use grpc build service
protobuf:
```syntax="proto3";
import "google/api/annotations.proto";
package test_grpc.api.file;
option go_package = ".;file";
message Request {
string uri = 1;
}
message Response {
string info = 1;
}
service File {
rpc GetFile (Request) returns (Response) {
option (google.api.http) = {
get: "/v1/{uri=files/*}"
};
}
rpc ListReputationHistories (Request) returns (Response) {
option (google.api.http) = {
post: "/v1/files:listReputationHistories"
};
}
}
```
service code.
```
func (s *FileServerImpl) GetFile(ctx context.Context, r *file.Request) (*file.Response, error) {
return &file.Response{Info: "GetFile:" + r.GetUri()}, nil
}
func (s *FileServerImpl) ListReputationHistories(ctx context.Context, r *file.Request) (*file.Response, error) {
return &file.Response{Info: "ListReputationHistories:" + r.GetUri()}, nil
}
```
I run service with prot:9201 .
# APISIX
upstreams:
```
curl -XPUT "http://127.0.0.1:9080/apisix/admin/upstreams/1" -H 'X-API-KEY: edd1c9f034335f136f87ad84b625c8f1' -d '{"nodes":{"host":"127.0.0.1:9201" : 1}, "type":"roundrobin", "name":"test_grpc_http"}'
```
routes:
```
curl -XPUT "http://127.0.0.1:9080/apisix/admin/routes/1" -H 'X-API-KEY: edd1c9f034335f136f87ad84b625c8f1' -d '{"uris":["/test/v1/files/*"],"name":"get_file1","methods":["GET"],"plugins":{"proxy-rewrite":{"regex_uri":["^/test/v1/files/(.+)","/v1/files/$1"]}},"upstream_id":"1"}'
curl -XPUT "http://127.0.0.1:9080/apisix/admin/routes/2" -H 'X-API-KEY: edd1c9f034335f136f87ad84b625c8f1' -d '{"uris":["/test/v1/files:listReputationHistories"],"name":"list_reputation_history1","methods":["POST"],"plugins":{"proxy-rewrite":{"uri":"/v1/files:listReputationHistories"}},"upstream_id":"1"}'
```
#Fact
I send any post request with prefix **/test/v1/files:** , result is same with **/test/v1/files:listReputationHistories**
for example:
curl "http://127.0.0.1:9080/test/v1/files:esxxx" -XPOST -d {"uri":"xxx"}
{"info":"ListReputationHistories:"}(base)
`
----------------------------------------------------------------
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] zhuliquan commented on issue #3134: I have some trouble on route match
Posted by GitBox <gi...@apache.org>.
zhuliquan commented on issue #3134:
URL: https://github.com/apache/apisix/issues/3134#issuecomment-751463366
# GRPC service
I use grpc build service
protobuf:
```syntax="proto3";
import "google/api/annotations.proto";
package test_grpc.api.file;
option go_package = ".;file";
message Request {
string uri = 1;
}
message Response {
string info = 1;
}
service File {
rpc GetFile (Request) returns (Response) {
option (google.api.http) = {
get: "/v1/{uri=files/*}"
};
}
rpc ListReputationHistories (Request) returns (Response) {
option (google.api.http) = {
post: "/v1/files:listReputationHistories"
};
}
}
```
service code.
```
func (s *FileServerImpl) GetFile(ctx context.Context, r *file.Request) (*file.Response, error) {
return &file.Response{Info: "GetFile:" + r.GetUri()}, nil
}
func (s *FileServerImpl) ListReputationHistories(ctx context.Context, r *file.Request) (*file.Response, error) {
return &file.Response{Info: "ListReputationHistories:" + r.GetUri()}, nil
}
```
I run service with prot:9201 .
# APISIX
upstreams:
```
curl -XPUT "http://127.0.0.1:9080/apisix/admin/upstreams/1" -H 'X-API-KEY: edd1c9f034335f136f87ad84b625c8f1' -d '{"nodes":{"host":"127.0.0.1:9201" : 1}, "type":"roundrobin", "name":"test_grpc_http"}'
```
routes:
```
curl -XPUT "http://127.0.0.1:9080/apisix/admin/routes/1" -H 'X-API-KEY: edd1c9f034335f136f87ad84b625c8f1' -d '{"uris":["/test/v1/files/*"],"name":"get_file1","methods":["GET"],"plugins":{"proxy-rewrite":{"regex_uri":["^/test/v1/files/(.+)","/v1/files/$1"]}},"upstream_id":"1"}'
curl -XPUT "http://127.0.0.1:9080/apisix/admin/routes/2" -H 'X-API-KEY: edd1c9f034335f136f87ad84b625c8f1' -d '{"uris":["/test/v1/files:listReputationHistories"],"name":"list_reputation_history1","methods":["POST"],"plugins":{"proxy-rewrite":{"uri":"/v1/files:listReputationHistories"}},"upstream_id":"333773215308464216"}'
```
#Fact
I send any post request with prefix ---/test/v1/files:--- , result is same with ---/test/v1/files:listReputationHistories---
for example:
curl "http://127.0.0.1:9080/test/v1/files:esxxx" -XPOST -d {"uri":"xxx"}
{"info":"ListReputationHistories:"}(base)
`
----------------------------------------------------------------
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 #3134: I have some trouble on route match
Posted by GitBox <gi...@apache.org>.
spacewander commented on issue #3134:
URL: https://github.com/apache/apisix/issues/3134#issuecomment-751730960
Added as https://github.com/api7/lua-resty-radixtree/issues/82
----------------------------------------------------------------
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] zhuliquan edited a comment on issue #3134: I have some trouble on route match
Posted by GitBox <gi...@apache.org>.
zhuliquan edited a comment on issue #3134:
URL: https://github.com/apache/apisix/issues/3134#issuecomment-751544555
> The characters with `:` in the `url` here are very similar to the prefix path, right? @spacewander
Yes, **/test/v1/files:/test/v1/files:listReputationHistories** and **/test/v1/files:xxxxxxx** will return same results, even I don't define route with **/test/v1/files:xxxxxxx**. APISIX ignore characters behind **':'** , only match string **"/test/v1/files"** before **':'**
----------------------------------------------------------------
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] zhuliquan commented on issue #3134: I have some trouble on route match
Posted by GitBox <gi...@apache.org>.
zhuliquan commented on issue #3134:
URL: https://github.com/apache/apisix/issues/3134#issuecomment-751463800
I have post my case in issue #3134发自我的华为手机-------- 原始邮件 --------发件人: Yuelin Zheng <no...@github.com>日期: 2020年12月27日周日 19:53收件人: apache/apisix <ap...@noreply.github.com>抄送: zhuliquan <zl...@sina.com>, Author <au...@noreply.github.com>主 题: Re: [apache/apisix] I have some trouble on route match (#3134)
Can you provide a minimal reproducible use case?
—You are receiving this because you authored the thread.Reply to this email directly, view it on GitHub, or unsubscribe.
----------------------------------------------------------------
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] zhuliquan edited a comment on issue #3134: I have some trouble on route match
Posted by GitBox <gi...@apache.org>.
zhuliquan edited a comment on issue #3134:
URL: https://github.com/apache/apisix/issues/3134#issuecomment-751463366
# GRPC service
I use grpc build service
protobuf:
```syntax="proto3";
import "google/api/annotations.proto";
package test_grpc.api.file;
option go_package = ".;file";
message Request {
string uri = 1;
}
message Response {
string info = 1;
}
service File {
rpc GetFile (Request) returns (Response) {
option (google.api.http) = {
get: "/v1/{uri=files/*}"
};
}
rpc ListReputationHistories (Request) returns (Response) {
option (google.api.http) = {
post: "/v1/files:listReputationHistories"
};
}
}
```
service code.
```
func (s *FileServerImpl) GetFile(ctx context.Context, r *file.Request) (*file.Response, error) {
return &file.Response{Info: "GetFile:" + r.GetUri()}, nil
}
func (s *FileServerImpl) ListReputationHistories(ctx context.Context, r *file.Request) (*file.Response, error) {
return &file.Response{Info: "ListReputationHistories:" + r.GetUri()}, nil
}
```
I run service with prot:9201, and use grpc-gateway provide http service.
# APISIX
upstreams:
```
curl -XPUT "http://127.0.0.1:9080/apisix/admin/upstreams/1" -H 'X-API-KEY: edd1c9f034335f136f87ad84b625c8f1' -d '{"nodes":{"host":"127.0.0.1:9201" : 1}, "type":"roundrobin", "name":"test_grpc_http"}'
```
routes:
```
curl -XPUT "http://127.0.0.1:9080/apisix/admin/routes/1" -H 'X-API-KEY: edd1c9f034335f136f87ad84b625c8f1' -d '{"uris":["/test/v1/files/*"],"name":"get_file1","methods":["GET"],"plugins":{"proxy-rewrite":{"regex_uri":["^/test/v1/files/(.+)","/v1/files/$1"]}},"upstream_id":"1"}'
curl -XPUT "http://127.0.0.1:9080/apisix/admin/routes/2" -H 'X-API-KEY: edd1c9f034335f136f87ad84b625c8f1' -d '{"uris":["/test/v1/files:listReputationHistories"],"name":"list_reputation_history1","methods":["POST"],"plugins":{"proxy-rewrite":{"uri":"/v1/files:listReputationHistories"}},"upstream_id":"1"}'
```
# Fact
I send any post request with prefix **/test/v1/files:** , result is same with **/test/v1/files:listReputationHistories**
for example:
curl "http://127.0.0.1:9080/test/v1/files:esxxx" -XPOST -d {"uri":"xxx"}
{"info":"ListReputationHistories:"}(base)

`
----------------------------------------------------------------
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