In ORY Oathkeeper I would like a request to the domain root to go to one server, and a request to a sub path to go to another server. So I defined two rules like this:
[
{
"id": "ping1",
"version": "v0.0.1",
"upstream": {
"url": "http://backend1/"
},
"match": {
"url": "http://<.*>/api/ping1",
"methods": ["GET"]
},
"authenticators": [{ "handler": "anonymous" }],
"authorizer": { "handler": "allow" },
"mutators": [{ "handler": "noop" }]
},
{
"id": "ping2",
"version": "v0.0.1",
"upstream": {
"url": "http://backend2/"
},
"match": {
"url": "http://<.*>",
"methods": ["GET"]
},
"authenticators": [{ "handler": "anonymous" }],
"authorizer": { "handler": "allow" },
"mutators": [{ "handler": "noop" }]
}
]
Accessing the root works. However, when I try to access the sub path ending with /api/ping1, I get "Expected exactly one rule but found multiple rules reason= request-id= status=500 "
I can get around this by not defining the root rule as
"url": "http://<.*>"
, but instead use the specific domain name.
This works:
"match": {
"url": "http://mydomainname.com",
"methods": ["GET"]
},
But, I would like to avoid that, and be able to put a wild card to match domain name there. Is there a way of making this work without explicitly specifying the domain name?
I found that it works with a wildcard if I add a slash att the end of the match url, like so:
{
"id": "ping2",
"version": "v0.0.1",
"upstream": {
"url": "http://backend2/"
},
"match": {
"url": "http://<.*>/", <--- SLASH ADDED AT END
"methods": ["GET"]
},
"authenticators": [{ "handler": "anonymous" }],
"authorizer": { "handler": "allow" },
"mutators": [{ "handler": "noop" }]
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With