1. The problem I’m having:
I am porting the example Nextcloud NGINX conf to Caddy. I have made it to about line 93, more or less. I am stuck on porting the NGINX variable $is_args
.
From the $is_args
documentation,
“
?
” if a request line has arguments, or an empty string otherwise
Is there a concise alternative to multiple matchers to port this block, assuming I am… mostly on the right track?
nginx.conf
# Rule borrowed from `.htaccess` to handle Microsoft DAV clients
location = / {
if ( $http_user_agent ~ ^DavClnt ) {
return 302 /remote.php/webdav/$is_args$args;
}
}
Caddyfile
# Rule borrowed from `.htaccess` to handle Microsoft DAV clients
(davclient) {
path /
header_regexp User-Agent ^DavClnt
}
@davclient {
import davclient
}
@davclientwithquery {
import davclient
not query ""
}
handle @davclientwithquery {
redir /remote.php/webdav/?{http.request.orig_uri.query} temporary
}
# Fall through match only no query?
handle @davclient {
redir /remote.php/webdav/ temporary
}
See also V2: Match empty query? - #3 by matt