I’m planning to use Caddy as a public reverse proxy to Solr.
Until now I’ve used a configuration like this:
the most importante piece of logic i need to port from Nginx is this: I need to limit the lenght (chars) of some http arguments (ie: ?rows=5000). How could I do this with Caddy?
if ($arg_start ~ ....+) {
return 403;
}
if ($arg_rows ~ ....+) {
return 403;
}
And in that expression you could then use functions like matches() for regex, or something more fun:
# `{http.request.uri.query.rows}` is a string,
# and the size() of a string describes its amount of chars
@prohibited expression size({http.request.uri.query.rows}) >= 4
# or write it as
@prohibited expression {http.request.uri.query.rows}.size() >= 4
# check if arg is not empty and convert it to an integer
@prohibited expression {http.request.uri.query.rows} != '' && int({http.request.uri.query.rows}) > 1500