Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bug: apisix 2.5 配置多个vars,跟匹配规则转发不一致 #4740

Closed
RalapZ opened this issue Aug 2, 2021 · 5 comments
Closed

bug: apisix 2.5 配置多个vars,跟匹配规则转发不一致 #4740

RalapZ opened this issue Aug 2, 2021 · 5 comments

Comments

@RalapZ
Copy link

RalapZ commented Aug 2, 2021

Issue description

Environment

centos7
apisix 三节点集群
Bug report without environment information will be ignored or closed.
1.

  • apisix version (cmd: apisix version): 2.5

  • OS (cmd: uname -a): Linux apisix-preprd-10-49-0-248.qcd.ak.lan 3.10.0-1127.19.1.el7.x86_64 change: added doc of how to load plugin. #1 SMP Tue Aug 25 17:23:54 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux

  • OpenResty / Nginx version (cmd: nginx -V or openresty -V):nginx version: openresty/1.19.3.1
    built by gcc 8.3.1 20190311 (Red Hat 8.3.1-3) (GCC)
    built with OpenSSL 1.1.1h 22 Sep 2020 (running with OpenSSL 1.1.1k 25 Mar 2021)
    TLS SNI support enabled
    configure arguments: --prefix=/usr/local/openresty/nginx --with-cc-opt='-O2 -DNGX_LUA_ABORT_AT_PANIC -I/usr/local/openresty/zlib/include -I/usr/local/openresty/pcre/include -I/usr/local/openresty/openssl111/include' --add-module=../ngx_devel_kit-0.3.1 --add-module=../echo-nginx-module-0.62 --add-module=../xss-nginx-module-0.06 --add-module=../ngx_coolkit-0.2 --add-module=../set-misc-nginx-module-0.32 --add-module=../form-input-nginx-module-0.12 --add-module=../encrypted-session-nginx-module-0.08 --add-module=../srcache-nginx-module-0.32 --add-module=../ngx_lua-0.10.19 --add-module=../ngx_lua_upstream-0.07 --add-module=../headers-more-nginx-module-0.33 --add-module=../array-var-nginx-module-0.05 --add-module=../memc-nginx-module-0.19 --add-module=../redis2-nginx-module-0.15 --add-module=../redis-nginx-module-0.3.7 --add-module=../ngx_stream_lua-0.0.9 --with-ld-opt='-Wl,-rpath,/usr/local/openresty/luajit/lib -L/usr/local/openresty/zlib/lib -L/usr/local/openresty/pcre/lib -L/usr/local/openresty/openssl111/lib -Wl,-rpath,/usr/local/openresty/zlib/lib:/usr/local/openresty/pcre/lib:/usr/local/openresty/openssl111/lib' --with-cc='ccache gcc -fdiagnostics-color=always' --with-pcre-jit --with-stream --with-stream_ssl_module --with-stream_ssl_preread_module --with-http_v2_module --without-mail_pop3_module --without-mail_imap_module --without-mail_smtp_module --with-http_stub_status_module --with-http_realip_module --with-http_addition_module --with-http_auth_request_module --with-http_secure_link_module --with-http_random_index_module --with-http_gzip_static_module --with-http_sub_module --with-http_dav_module --with-http_flv_module --with-http_mp4_module --with-http_gunzip_module --with-threads --with-compat --with-stream --with-http_ssl_module

  • etcd version, if have (cmd: run curl http://127.0.0.1:9090/v1/server_info to get the info from server-info API): etcdctl version: 3.4.10
    API version: 3.4

  • apisix-dashboard version, if have: 2.6

  • luarocks version, if the issue is about installation (cmd: luarocks --version):/usr/local/bin/luarocks 3.4.0

Minimal test code / Steps to reproduce the issue

Bug report without steps to reproduce will be ignored or closed.

1."plugins": {
"traffic-split": {
"disable": false,
"rules": [
{
"match": [
{
"vars": [
[
"http_platform_code",
"==",
"10003"
]
]
}
],
"weighted_upstreams": [
{
"upstream": {
"hash_on": "vars",
"name": "upstream_A",
"nodes": {
"10.49.8.2:8083": 10
},
"pass_host": "pass",
"scheme": "http",
"type": "roundrobin"
},
"weight": 1
}
]
},
{
"match": [
{
"vars": [
[
"http_platform_code",
"==",
"10004"
]
]
}
],
"weighted_upstreams": [
{
"upstream": {
"hash_on": "vars",
"name": "upstream_C",
"nodes": {
"10.49.8.2:8084": 10
},
"pass_host": "pass",
"scheme": "http",
"type": "roundrobin"
},
"weight": 1
}
]
},
配置多个rule的情况,会出现乱匹配的情况
以下是都是执行命令 curl -X POST http://multiplate-test.naloc.cn/apis/fulfillment/create -H "platform_code:10004"的结果
image

What's the actual result? (including assertion message & call stack if applicable)

image

What's the expected result?

期望结果应该是
curl -X POST http://multiplate-test.naloc.cn/apis/fulfillment/create -H "platform_code:10004 " 匹配走10.49.8.2:8084
curl -X POST http://multiplate-test.naloc.cn/apis/fulfillment/create -H "platform_code:10003” 匹配走 10.49.8.2:8083

@tokers
Copy link
Contributor

tokers commented Aug 2, 2021

@RalapZ Please re-format the configuration.

@tokers
Copy link
Contributor

tokers commented Aug 2, 2021

Also, the 502 is abnormal, are you sure the backend services are available and the networking between APISIX and them are healthy?

@RalapZ
Copy link
Author

RalapZ commented Aug 2, 2021

Also, the 502 is abnormal, are you sure the backend services are available and the networking between APISIX and them are healthy?
{
"uris": [
"/apis/*"
],
"name": "xxx",
"methods": [
"GET",
"POST",
"PUT",
"DELETE",
"PATCH",
"HEAD",
"OPTIONS",
"CONNECT",
"TRACE"
],
"hosts": [
"xxxx"
],
"plugins": {
"traffic-split": {
"disable": false,
"rules": [
{
"match": [
{
"vars": [
[
"http_platform_code",
"==",
"10003"
]
]
}
],
"weighted_upstreams": [
{
"upstream": {
"hash_on": "vars",
"name": "upstream_A",
"nodes": {
"10.49.8.2:8083": 10
},
"pass_host": "pass",
"scheme": "http",
"type": "roundrobin"
},
"weight": 1
}
]
},
{
"match": [
{
"vars": [
[
"http_platform_code",
"==",
"10004"
]
]
}
],
"weighted_upstreams": [
{
"upstream": {
"hash_on": "vars",
"name": "upstream_C",
"nodes": {
"10.49.8.2:8084": 10
},
"pass_host": "pass",
"scheme": "http",
"type": "roundrobin"
},
"weight": 1
}
]
},
{
"match": [
{
"vars": [
[
"http_platform_code",
"==",
"10005"
]
]
}
],
"weighted_upstreams": [
{
"upstream": {
"hash_on": "vars",
"name": "upstream_D",
"nodes": {
"10.49.8.2:8085": 10
},
"pass_host": "pass",
"scheme": "http",
"type": "roundrobin"
},
"weight": 1
}
]
},
{
"match": [
{
"vars": [
[
"http_platform_code",
"==",
"10006"
]
]
}
],
"weighted_upstreams": [
{
"upstream": {
"hash_on": "vars",
"name": "upstream_E",
"nodes": {
"10.49.8.2:8086": 10
},
"pass_host": "pass",
"scheme": "http",
"type": "roundrobin"
},
"weight": 1
}
]
},
{
"match": [
{
"vars": [
[
"http_platform_code",
"==",
"10007"
]
]
}
],
"weighted_upstreams": [
{
"upstream": {
"hash_on": "vars",
"name": "upstream_F",
"nodes": {
"10.49.8.2:8087": 10
},
"pass_host": "pass",
"scheme": "http",
"type": "roundrobin"
},
"weight": 1
}
]
},
{
"match": [
{
"vars": [
[
"http_platform_code",
"==",
"10008"
]
]
}
],
"weighted_upstreams": [
{
"upstream": {
"hash_on": "vars",
"name": "upstream_B",
"nodes": {
"10.49.8.2:8088": 10
},
"pass_host": "pass",
"scheme": "http",
"type": "roundrobin"
},
"weight": 1
}
]
}
]
}
},
"upstream": {
"nodes": [
{
"host": "10.49.8.11",
"port": 655,
"weight": 10
}
],
"timeout": {
"connect": 6,
"read": 6,
"send": 6
},
"type": "roundrobin",
"scheme": "http",
"pass_host": "pass"
},
"status": 1
}
this is all my configuration;
the backend services are unavailable,this is not the problem ;but the proxy result not match my expection

@spacewander
Copy link
Member

Fixed by #4092?

@RalapZ
Copy link
Author

RalapZ commented Aug 3, 2021

Fixed by #4092?

well done ,solve my problem

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants