Issue description
目的:想要根据分流规则,比如-H "user-name:test",改变Host让流量跑到k8s集群中不同的ingress。
实现方法:使用nginx做为ingress controller,流量根据规则转向同一个k8s里的不同ingress。apisix的route中,nodes里面填的是同一个k8s集群ingress controller的地址,根据规则把upstream_host改为ingress服务的host。详细配置见下面
遇到问题:traffic-split里面的upstream通过upstream_host字段不能正确改变Host值,访问时报错404,不把upstream配在traffic-split里时没问题
Environment
- apisix version (cmd:
apisix version): 2.4
- OS (cmd:
uname -a): Ubuntu 16.04.2 LTS
- OpenResty / Nginx version (cmd:
nginx -V or openresty -V): openresty/1.19.3.1
- 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.13
- apisix-dashboard version, if have: 2.4
路由配置
curl http://127.0.0.1:9080/apisix/admin/routes/10 -H 'X-API-KEY: edd1c9f034335f136f87ad84b625c8f1' -X PUT -d '
{
"uri": "/route10",
"plugins": {
"traffic-split": {
"rules": [
{
"match": [
{
"vars": [
["http_username", "==", "test"]
]
}
],
"weighted_upstreams": [
{
"upstream": {
"type": "roundrobin",
"pass_host": "rewrite",
"upstream_host": "echo-headers.pro.test-k8s.qslocal.com",
"nodes": {
"10.255.1.107:80":1,
"10.255.1.108:80":1
}
}
}
]
}
]
}
},
"upstream": {
"type": "roundrobin",
"pass_host": "rewrite",
"upstream_host": "echo-headers.pro.test-k8s.qslocal.com",
"nodes": {
"10.255.1.107:80":1,
"10.255.1.108:80":1
}
}
}'
What's the actual result? (including assertion message & call stack if applicable)
traffic-split插件中upstream_host改变没生效,流量到不了相应host的ingress,报错404
Issue description
目的:想要根据分流规则,比如-H "user-name:test",改变Host让流量跑到k8s集群中不同的ingress。
实现方法:使用nginx做为ingress controller,流量根据规则转向同一个k8s里的不同ingress。apisix的route中,nodes里面填的是同一个k8s集群ingress controller的地址,根据规则把upstream_host改为ingress服务的host。详细配置见下面
遇到问题:traffic-split里面的upstream通过upstream_host字段不能正确改变Host值,访问时报错404,不把upstream配在traffic-split里时没问题
Environment
apisix version): 2.4uname -a): Ubuntu 16.04.2 LTSnginx -Voropenresty -V): openresty/1.19.3.1curl http://127.0.0.1:9090/v1/server_infoto get the info from server-info API): 3.4.13路由配置
What's the actual result? (including assertion message & call stack if applicable)
traffic-split插件中upstream_host改变没生效,流量到不了相应host的ingress,报错404