apisix
apisix copied to clipboard
help request: How to set the upstream host dynamically
Description
I'm trying to set the upstream host dynamically and unknown in advance like this:
remote_uri: /api/data-manage/... then set the host to: data-manage
I've tried the proxy-rewrite and the custom balancer, but still can't get this to work.
Is there any suggestion?
refer to: https://github.com/apache/apisix/discussions/9487#discussion-5199631
Environment
- APISIX version:
3.1.0
- Operating system:
Linux gateway-5667d89f79-vl75g 5.4.164-1.el7.elrepo.x86_64 #1 SMP Mon Dec 6 12:28:33 EST 2021 x86_64 GNU/Linux
- OpenResty / Nginx version:
nginx version: openresty/1.21.4.1
Can you show how to reproduce it?
Can you show how to reproduce it?
It's not a bug report, I just want to do the above-mentioned function, need some help, thank you!
Can you show how to reproduce it?
It's not a bug report, I just want to do the above-mentioned function, need some help, thank you!
Can you show an example config of route that you tried with which didn't work?
try the traffic-split plugin @KamenRiderKuuga
Can you show how to reproduce it?
It's not a bug report, I just want to do the above-mentioned function, need some help, thank you!
Can you show an example config of route that you tried with which didn't work?
No example configuration now.
I want to set the request regexp like this:
In this way, when requesting /api/data-manage/users
, the http://data-manage/api/data-manage/users
will be requested.
try the traffic-split plugin @KamenRiderKuuga
Thanks, I'll try it.
@qihaiyan I tried the traffic-split
, it can't dynamically assign value to upstream_host according to the URI regexp.
@qihaiyan I tried the
traffic-split
, it can't dynamically assign value to upstream_host according to the URI regexp.
Maybe you should develop your own plugin with reference to traffic-split.
this is not supported.
I have the same problem, and I write a custom plugin to achieve this.
checkout my gits: https://gist.github.com/br41n10/e2d378c7a04d4861b2f0cbf4d2476d71
This is a very basic implementation, modify on your needs.
i have the same problem,i write a customer plugin, but i don' known which is the best way? https://github.com/apache/apisix/issues/11342