Port of NGINX $is_args variable

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

If there’s no query, there’s not really any harm in including ? in the URL.

Just do redir /remote.php/webdav/?{query}

Please don’t delete the help topic template. It’s important that you properly fill it out so that we get proper context for your question. It’s a forum rule.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.