How to set the upstream host dynamically #9487
Replies: 2 comments
-
I have similar needs to you. My requirement is to parse the tenant ID in the token in the request, then obtain the cluster address corresponding to the tenant from redis based on the tenant ID, and then dynamically route to different upstreams. The following is my part Implementation, for your reference, I hope it can inspire you:
|
Beta Was this translation helpful? Give feedback.
-
Hi @KamenRiderKuuga & @xBoo, I had the same concern and below is how I fixed the issue. I added proxy-rewrite plugin to capture the parameter from URL and add it to a custom header.
Then I wrote a custom lua plugin to override the host. This plugin will take the
Once enabled, this plugin will override the host from I have a repository which I used for knative networking, which has the same issue. You can refer it here: https://github.com/PasanBhanu/apisix-knative-kourier-routing-plugin. For the guidance on how to add the custom plugin, you can refer to above repo which has a detailed guideline on how to do that. Hope this helps 🫰 |
Beta Was this translation helpful? Give feedback.
-
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?
Beta Was this translation helpful? Give feedback.
All reactions