How to use regular expression in Cluster Address ?
Hello. I have several addresses, some of which are variable
https://localhost:5000/viewer/10.2.410.2010029.100002.2022084318?wadouri=abdc
https://localhost:5001/viewer/1.2.410.20029.00002.20220207084318?wadouri=ef
https://localhost:5002/viewer/17.2.410.200029.002.2022020718?wadouri=fav
10.2.410.2010029.100002.2022084318 1.2.410.20029.00002.20220207084318 17.2.410.200029.002.2022020718
How can I use regex instead of these strings? example :
"Clusters": {
"cluster1": {
"Destinations": {
"destination1": {
"Address": "https://localhost:5000/viewer/regex(?)?wadouri=abdc"
}
}
},
What sort of modifications did you want to make to the destination address?
If all you are changing is the host and keeping the path the same, you can set the Address to https://localhost:5000/, as that indicates the prefix used, not the final URL.
E.g. with a request to https://localhost:5002/viewer/123.456.789?wadouri=fav and "Address": "https://localhost:5000/", the request to the backend would be https://localhost:5000/viewer/123.456.789?wadouri=fav.
If you wanted to make modifications (e.g. move which segment the unique value is in), you can look at https://microsoft.github.io/reverse-proxy/articles/transforms.html
The problem is in addressing, not transform
Can you share a few examples of how you're hoping to proxy requests? It's not clear to me from your description.
E.g.
https://proxy/foo => https://backend/foo
...
Can you share a few examples of how you're hoping to proxy requests? It's not clear to me from your description.
E.g.
https://proxy/foo => https://backend/foo ...
I have a service that can open the corresponding file based on a specific value. This service is located on different servers. I want to put these services behind yarp regardless of the specific value.
specific value example : 10.2.410.2010029.100002.20220843218
specific value example : 102.2.410.201043029.100002.20222084318
specific value example : 10.2.410.2010029.1030002.202203384318
specific value example : 10.2.410.201230029.10220002.20220384318
which changes for each request
"Clusters": {
"cluster1": {
"Destinations": {
"destination1": {
"Address": "https://localhost:5000/viewer/{specific value}?wadouri=abdc"
}
}
},
"Clusters": {
"cluster2": {
"Destinations": {
"destination1": {
"Address": "https://localhost:5001/viewer/{specific value}?wadouri=abdc"
}
}
},
"Clusters": {
"cluster3": {
"Destinations": {
"destination1": {
"Address": "https://localhost:5002/viewer/{specific value}?wadouri=abdc"
}
}
},
I want to use regex instead of these values
Can you include the routes as well? E.g. How do you decide which request goes to which cluster?
Can you include the routes as well? E.g. How do you decide which request goes to which cluster?
"ReverseProxy": {
"Routes": {
"route1": {
"ClusterId": "cluster1",
"CorsPolicy": "customPolicy",
"Match": {
"Path": "/s1/{**catch-all}"
},
"Transforms": [
{ "PathPattern": "{**catch-all}" }
]
},
"route2": {
"ClusterId": "cluster2",
"CorsPolicy": "customPolicy",
"Match": {
"Path": "/s2/{**catch-all}"
},
"Transforms": [
{ "PathPattern": "{**catch-all}" }
]
},
"route3": {
"ClusterId": "cluster3",
"CorsPolicy": "customPolicy",
"Match": {
"Path": "/s3/{**catch-all}"
},
"Transforms": [
{ "PathPattern": "{**catch-all}" }
]
},
Url manipulation should be done by route transforms, not destination. Try this:
"ReverseProxy": {
"Routes": {
"route1": {
"ClusterId": "cluster1",
"CorsPolicy": "customPolicy",
"Match": {
"Path": "/s1/{**catch-all}"
},
"Transforms": [
{ "PathPattern": "/viewer/{**catch-all}" },
{ "QueryValueParameter": "wadouri", "Append": "abdc" }
]
},
"route2": {
"ClusterId": "cluster2",
"CorsPolicy": "customPolicy",
"Match": {
"Path": "/s2/{**catch-all}"
},
"Transforms": [
{ "PathPattern": "/viewer/{**catch-all}" },
{ "QueryValueParameter": "wadouri", "Append": "abdc" }
]
},
"route3": {
"ClusterId": "cluster3",
"CorsPolicy": "customPolicy",
"Match": {
"Path": "/s3/{**catch-all}"
},
"Transforms": [
{ "PathPattern": "/viewer/{**catch-all}" },
{ "QueryValueParameter": "wadouri", "Append": "abdc" }
]
},
"Clusters": {
"cluster1": {
"Destinations": {
"destination1": {
"Address": "https://localhost:5000/"
}
}
},
"cluster2": {
"Destinations": {
"destination1": {
"Address": "https://localhost:5001/"
}
}
},
"cluster3": {
"Destinations": {
"destination1": {
"Address": "https://localhost:5002/"
}
}
},
Triage: Looks to answered above, closing. Feel free to reopen if we got it wrong.