I want to design a proxy that retrieves backend url from kvm ...
If your backend host is static but the path is varying, you could use a load balancer for the host and retrieve the path from your KVM as a variable that gets passed into the path parameter
Load balancer: https://docs.apigee.com/api-platform/deploy/load-balancing-across-backend-servers
There are generally two ways to make a target backend configurable:
Using option 2, you could look up the complete target URL from a KVM and set it in the Target PreFlow. For example, given the variable in <Ref> is populated from a KVM:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?> <AssignMessage continueOnError="false" enabled="true" name="AM-Target-URL"> <DisplayName>AM-Target-URL</DisplayName> <!-- Put in target pre flow --> <AssignVariable> <Name>target.url</Name> <Ref>flow.target.scheme_host_basepath_and_suffix</Ref> </AssignVariable> <IgnoreUnresolvedVariables>false</IgnoreUnresolvedVariables> <AssignTo createNew="false" transport="http" type="request"/> </AssignMessage>
NOTE: you must set target.url in the Target flow and that the Target Server <URL> is not used.
<HTTPTargetConnection> <!-- URL gets overwritten by AM-Target-URL --> <URL>https://dummy.url</URL> </HTTPTargetConnection>
Please explain it is not clear for a newbie...
Sometimes it's better to learn by doing. Here are the steps and links to documentation for the simple case in option 2.
Notice the difference between the request URL "/echo/params" and the target URL shown in the trace image.
Try it out, you'll undoubtedly will learn something new.
Do I give a target when i create the proxy or make it no target?@Kurt Googler Kanaskie
As per Kurt's note, you need to set a target. This can be any temporary address that will later be overridden.
Please respond via comments, not as a new answer.
Yes, provide a target endpoint as per
<HTTPTargetConnection> <!-- target.url gets overwritten by AM-Target-URL --> <URL>https://dummy.url</URL> </HTTPTargetConnection>
Using a Target Server you could use:
<HTTPTargetConnection> <LoadBalancer> <Server name="parameterize-target-endpoint"/> </LoadBalancer> <!-- Separate basepath and suffix <Path>{flow.target.basepath}/{flow.target.suffix}</Path> --> <!-- both in one variable --> <Path>{flow.target.basepath_and_suffix}</Path> </HTTPTargetConnection>
I am not able to understand how we are going to override it?I am getting a 503 error?dane knezic
See above and please remember to use "Add comment"
seturldynamicallyfromkvm-rev3-2019-07-24.zip . Sorry not able to make it work.Not able to assign target endpoint from assign message policy.
I have attached the proxy.Please help....
I have fixed your proxy now you can see the target url is coming from KVM.
8898-seturldynamicallyfromkvm-rev3-2019-07-24-rev3.zip
you were not configuring the KVM policy properly, take a look at the sample i have fixed.
1. I have done two things. Moved KVM in proxy preflow.
2. Fixed the variable naming
Here are the steps for you to test this proxy.
- Create KVM with name backendtargetservers
- Create a key value in the KVM backendtargetservers
key - scheme_host_basepath_and_suffix
value - http://httpbin.org/get
screen-shot-2019-07-24-at-50037-pm.png
Upload the proxy and deploy that. you will see screen-shot-2019-07-24-at-50152-pm.png
Thanks it works...
User | Count |
---|---|
7 | |
2 | |
2 | |
1 | |
1 |