Basic auth fileserver not working

1. Caddy version (caddy version):

v2.1.1 (compiled it myself but changed nothing)

2. How I run Caddy:

a. System environment:

Ubuntu 18.04 LTS

b. Command:

sudo caddy run

d. My complete Caddyfile or JSON config:

example.dev {
    root * /home/max/files
    basicauth /home/max/files/* {
        [username] [hashed pw]
    }

file_server browse

}

3. The problem I’m having:

There is no auth popup, can access all files.

4. Error messages and/or full log output:

No error messages. It’s telling me this though:

http	server is listening only on the HTTPS port but has no TLS connection policies; adding one to enable TLS	{"server_name": "srv0", "https_port": 443}

but as .dev is a secure namespace and I can access the site everything seems to work.

5. What I already tried:

I thought maybe it’s a cache / cookies problem. So I tried it via curl, other device, and clearing the browser storage. But no auth popup.

Any help would be very appreciated:)

What is the exact request you’re making that isn’t getting prompted for auth? (paste a curl command, for example)

The mainroute (curl https://example.dev)

There’s no auth on that request, because you’ve scoped auth to only match requests with a path starting with /home/max/files/.

Looking at that twice, it’s the same as your HTML root. Put it there by accident? Just remove that from your basicauth line.

Ahh, thanks a lot! I thought I would have to specify the folder, not the route retclative to root… I just started using caddy, so forgive me those rookie mistakes:) I could search a bit on google but you might know the perfect answer, so quick question: Is there any addon which features a better file browser? Like downloading whole folders etc.? Maybe even upload for some users? (It should still be Caddy, not something like filerun)

I think this is exactly what you’re looking for:

The project was archived for a time, but recently found a new maintainer! :tada:

It used to be implemented as a plugin for Caddy with a standalone option, but it’s now simply a standalone application. To use it with Caddy, you would run it alongside Caddy and have Caddy reverse_proxy to it.

Thanks a lot! I’ll look into it:)

I know this is probably not the right place… but I only see the spinner animation when trying to spin up filebrowser… Any ideas? Do i need to download / make a frontend or something?

I’m not sure what you mean - but no, the frontend is integrated. Is it just a misconfiguration? I’m no expert on that app though, I’m not sure how to help.

You might want to try asking the filebrowser developers for help with it!

Problem was that I proxied only like this reverse_proxy /files 127.0.0.1:8080.
With reverse_proxy /files/* 127.0.0.1:8080 it’s working. Thanks a lot again:) You can close this now @matt.

3 Likes

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