Caddy: query request matcher support regex or wildcards?

Created on 24 Apr 2020  路  6Comments  路  Source: caddyserver/caddy

https://caddyserver.com/docs/caddyfile/matchers#query

The query matcher just says key and value and I'm wondering if those keys/values just be statically defined or if regex or wildcards can be used.

documentation question

All 6 comments

Params need to be exact matches (case sensitive currently, I think, but this may change) and vals support exact matches and single * wildcard (no prefix/suffix matches or regex currently).

https://github.com/caddyserver/caddy/blob/master/modules/caddyhttp/matchers.go#L372-L385

Do you have a specific usecase where you need more than that?

I'll see that we update the docs to clarify that.

I don't think I need any more than this, rd=* would be sufficient.

I'm looking to implement this but using Caddy:

https://www.callumpember.com/Kubernetes-A-Single-OAuth2-Proxy-For-Multiple-Ingresses/

Is there a way to get the _value_ of a query option?

example url

https://foo.bar/something?rd=/baz

I want to redirect to another host with the /baz path

You can use the {query} placeholder to grab the entire query, or you can use the longer form {http.request.uri.query.*} to grab specific query params (where * is the key you want).

Further questions that aren't specifically about bugs or a feature request should go on the forums: https://caddy.community

If you do have a feature request, best to open a new issue at this point to track it, because this issue veered a bit off-track. It's still okay to discuss here, but since there's nothing actionable here, I'll close this issue.

We could probably allow the use of placeholders.

ok, ya, the placeholder works. thanks for the responses. I'll move further questions to the forums.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

treviser picture treviser  路  3Comments

wayneashleyberry picture wayneashleyberry  路  3Comments

lorddaedra picture lorddaedra  路  3Comments

muhammadmuzzammil1998 picture muhammadmuzzammil1998  路  3Comments

mikolysz picture mikolysz  路  3Comments