File_server: only show specified sub-folders

1. The problem I’m having:

Hi
Sorry if this was already documented or asked somewhere, I’m new to Caddy and maybe I misunderstood some information.

I’m trying to specify only 1 subdirectory in one of my directories to allow access to.
I’m using Modules - Caddy Documentation to mount a bucket as a filesystem. And inside the bucket (which contains lots of folders) I want to show only one specific folder.

I saw there is hide directive, but I don’t want to make an explicit deny list.

Thanks for your help

2. Error messages and/or full log output:

3. Caddy version:

2.10.2

4. How I installed and ran Caddy:

a. System environment:

Ubuntu 24.04

b. Command:

caddy run

c. Service/unit/compose file:

d. My complete Caddy config:

Here is my current minimal configuration:

{
	filesystem foo-bucket s3 {
		bucket foo-bucket
	}
}

http://example.com:1234 {
    handle /foo-bucket* {
        # TODO: when hit http://example.com:1234/foo-bucket  only list the subfolder `foo` 
        uri strip_prefix /foo-bucket
        file_server browse {
            fs foo-bucket
        }
    }

    handle {
        file_server browse {
            root /www
        }
    }
}

5. Links to relevant resources:

I saw Limit root to specified folders - #4 by francislavoie, but in my understanding, this is different. It allows navigation only to /images or /docs, but other folders are still listed in the webpage :thinking:

i don’t understand how it could be that way.

	handle_path /docs* {
		root * a:/docs
		file_server browse
	}

in that example if you go to url /docs it will show the content of file system directory /docs

Let’s say I have the following structure:

\_ data
    \_ foo
    \_ bar

When I go to localhost/data I want to see (on the webpage from a browser) only :

    \_ foo

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