Internal directive - Use of Wildcard

I’m trying to use the ‘internal’ caddy directive to protect certain file types (extensions) from outside access. Rather than specifying each directory structure (and forgetting to add a new one in the future), I’d like to use a wildcard. Allow me to illustrate:

Here is the directory structure:

/www/websites/rpc.site.com #root (index, etc)
the .inc files reside in methods folder…
/www/websites/rpc.site.com/slhs/methods
but may reside in any new path I create…
/www/websites/rpc.site.com/kount/methods
( and others )

How can I do something similar to this:

internal */methods

Or better yet…

internal *.inc #any .inc file, anywhere

It doesn’t seem to work, and I’m not sure if it’s expecting a REGEX perhaps.

Hi @LewPayne,

internal doesn’t accept globs, wildcards, or regex. It accepts a literal string base path, which is then compared to the path requested by the client.

rewrite goes off before internal does, so you could use that to find those extensions and rewrite them to an internal path… But there’s a few major issues with that approach, namely that you can use it to deny access, but making actual legitimate access available after the rewrite is troublesome.

You could open a feature request on the Github repo for a change to the internal directive, if you like.

https://github.com/mholt/caddy/issues

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