Specify Caddyfile when running a file-server

1. Caddy version (caddy version):

➜  ~ caddy version
v2.5.0-beta.1 h1:lF5wWqqDJ6HjETbnBILvTAeKcThsz1+OeWB+d1tWxp4=

2. How I run Caddy:

➜ ~ caddy file-server --root ~/Downloads --browse --listen :4040

a. System environment:

  • Mac OS 12.3
  • Using a community-maintained version:

b. Command:

➜  ~ caddy file-server --root ~/Downloads --browse --listen :4040
2022/03/29 16:07:40.721	WARN	admin	admin endpoint disabled
2022/03/29 16:07:40.721	INFO	tls.cache.maintenance	started background certificate maintenance	{"cache": "0xc0002bd7a0"}
2022/03/29 16:07:40.722	INFO	tls	cleaning storage unit	{"description": "FileStorage:/Users/arun/Library/Application Support/Caddy"}
2022/03/29 16:07:40.722	INFO	tls	finished cleaning storage units
2022/03/29 16:07:40.722	INFO	autosaved config (load with --resume flag)	{"file": "/Users/arun/Library/Application Support/Caddy/autosave.json"}
2022/03/29 21:37:40 Caddy 2 serving static files on :4040

c. Service/unit/compose file:

Not applicable.

d. My complete Caddyfile or JSON config:


3. The problem I’m having:

I’d like to understand how I can specify a custom Caddyfile that I have on my downloads folder.

4. Error messages and/or full log output:

Trying the following command doesn’t work:

➜  ~ caddy file-server --root ~/Downloads --browse --listen :4040 --config ~/Downloads/Caddyfile
flag provided but not defined: -config
Usage of file-server:
    	Enable the access log
    	Enable directory browsing
  -domain string
    	Domain name at which to serve the files
  -listen string
    	The address to which to bind the listener
  -root string
    	The path to the root of the site
    	Enable template rendering

5. What I already tried:

  • Tried specifying with --config but it’s not a valid command for file-server
  • I have also reviewed this page, but a bit unclear:

6. Links to relevant resources:

Mentioned above.

The file-server command doesn’t accept a config file, use caddy run instead:

caddy run --config ~/Downloads/Caddyfile

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