For example, if the parameters of the plugin are configured with 1, after a period of business logic analysis, it will jump to upstream1, and if configured with 2, it will jump to 2.I try to do,but fail.It always redirect to upstream1 because my route’s server config is upstream1 .
**function MyPlugin:access(plugin_conf)
kong.service.set_upstream(“upstream1Name”)**
I know it is easy to do it in openresty by
proxy_pass http://$backend/myMethod
Hi @ilovechairmao - as far as concern to my knowledge, you cannot implement this logic, not even in the custom plugin.
Now, you may ask me, why ? answer is, one service can have one or more routes but not vice a versa.
I am not sure this is possible but you can try…
You can have your above logic to call direct backend endpoints from the custom plugin. Keep this plugin in service scope and get the response from one of the backend/upstream endpoint as per your logic.
In the service section, try to terminate the request so that it will not call any backend/upsteam endpoint configured in the service. make sure you configure any dummy hostname in the service section.
You can refer OAuth2 plugin.
1 Like
I can easy to do it in openresty config file. If I edit the kong config file to add this code, and also config the upstream via Konga website, Will these two configurations affect each other? Is it ultimately based on Konga’s configuration? Or do I say that the two configuration methods will be mixed together? I can find the Kong config file in the server, which is the openrest file