Treating every file in a file_server as a download

1. Output of caddy version:

v2.6.2 h1:wKoFIxpmOJLGl3QXoo6PNbYvGW4xLEgo32GPBEjWL8o=

2. How I run Caddy:

I run a command prompt window on Windows.

a. System environment:

Windows 10, 19045.2251

b. Command:

caddy run

d. My complete Caddy config:

[subdomain1].[domain].[tld] {
	reverse_proxy 192.168.1.112:2086
	tls {
		dns cloudflare [api key]
	}
}

[subdomain2].[domain].[tld] {
	reverse_proxy 192.168.1.112:8096
	tls {
		dns cloudflare [api key]
	}
}

[subdomain3].[domain].[tld] {
	file_server browse
	tls {
		dns cloudflare [api key]
	}
}

3. The problem I’m having:

When making a file_server, the browser treats every file like text, not as binary data. That means it tries to process it to display, rather that download it. I just want the browser to download everything.

4. Error messages and/or full log output:

2022/11/12 01:06:42.145 ←[34mINFO←[0m   using adjacent Caddyfile
2022/11/12 01:06:42.151 ←[33mWARN←[0m   Caddyfile input is not formatted; run the 'caddy fmt' command to fix inconsistencies    {"adapter": "caddyfile", "file": "Caddyfile", "line": 21}
2022/11/12 01:06:42.154 ←[34mINFO←[0m   admin   admin endpoint started  {"address": "localhost:2019", "enforce_origin": false, "origins": ["//localhost:2019", "//[::1]:2019", "//127.0.0.1:2019"]}
2022/11/12 01:06:42.154 ←[34mINFO←[0m   tls.cache.maintenance   started background certificate maintenance      {"cache": "0xc0003fe700"}
2022/11/12 01:06:42.154 ←[34mINFO←[0m   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}
2022/11/12 01:06:42.154 ←[34mINFO←[0m   http    enabling automatic HTTP->HTTPS redirects        {"server_name": "srv0"}
2022/11/12 01:06:42.154 ←[34mINFO←[0m   tls     cleaning storage unit   {"description": "FileStorage:C:\\Users\\Web Servicing\\AppData\\Roaming\\Caddy"}
2022/11/12 01:06:42.154 ←[34mINFO←[0m   http.log        server running  {"name": "remaining_auto_https_redirects", "protocols": ["h1", "h2", "h3"]}
2022/11/12 01:06:42.154 ←[34mINFO←[0m   http    enabling HTTP/3 listener        {"addr": ":443"}
2022/11/12 01:06:42.154 ←[34mINFO←[0m   http.log        server running  {"name": "srv0", "protocols": ["h1", "h2", "h3"]}
2022/11/12 01:06:42.154 ←[34mINFO←[0m   http    enabling automatic TLS certificate management   {"domains": ["[redacted]", "[redacted]", "[redacted]"]}
2022/11/12 01:06:42.161 ←[34mINFO←[0m   autosaved config (load with --resume flag)      {"file": "C:\\Users\\Web Servicing\\AppData\\Roaming\\Caddy\\autosave.json"}
2022/11/12 01:06:42.161 ←[34mINFO←[0m   serving initial configuration
2022/11/12 01:06:42.161 ←[34mINFO←[0m   tls     finished cleaning storage units

5. What I already tried:

  • used Free Download Manager (tries to process the binary file as a list of URL’s, infinite loading)
  • curl -v, displays this:
{ [2050 bytes data]
* schannel: failed to decrypt data, need more data
{ [98548 bytes data]
* schannel: failed to decrypt data, need more data
* schannel: failed to decrypt data, need more data
{ [21145 bytes data]
* schannel: failed to decrypt data, need more data
{ [32768 bytes data]
* schannel: failed to decrypt data, need more data
{ [65536 bytes data]
* schannel: failed to decrypt data, need more data
* schannel: failed to decrypt data, need more data
{ [16384 bytes data]
* schannel: failed to decrypt data, need more data
* schannel: failed to decrypt data, need more data
{ [16384 bytes data]
* schannel: failed to decrypt data, need more data
{ [32768 bytes data]
* schannel: failed to decrypt data, need more data
{ [32768 bytes data]
* schannel: failed to decrypt data, need more data
* schannel: failed to decrypt data, need more data
{ [16384 bytes data]
* schannel: failed to decrypt data, need more data
{ [32768 bytes data]
* schannel: failed to decrypt data, need more data
{ [32768 bytes data]
* schannel: failed to decrypt data, need more data
{ [32768 bytes data]
* schannel: failed to decrypt data, need more data
* schannel: failed to decrypt data, need more data
{ [16384 bytes data]
* schannel: failed to decrypt data, need more data
{ [65536 bytes data]
* schannel: failed to decrypt data, need more data
{ [32768 bytes data]
* schannel: failed to decrypt data, need more data
{ [32768 bytes data]
* schannel: failed to decrypt data, need more data
{ [32768 bytes data]
* schannel: failed to decrypt data, need more data
{ [32768 bytes data]
* schannel: failed to decrypt data, need more data
{ [32768 bytes data]
* schannel: failed to decrypt data, need more data
  0 1728M    0 1150k    0     0  1409k      0  0:20:55 --:--:--  0:20:55 1409k{ [65536 bytes data]
* schannel: failed to decrypt data, need more data
{ [32768 bytes data]
* schannel: failed to decrypt data, need more data
{ [49152 bytes data]
* schannel: failed to decrypt data, need more data
{ [32768 bytes data]
* schannel: failed to decrypt data, need more data
* schannel: failed to decrypt data, need more data
{ [49152 bytes data]
* schannel: failed to decrypt data, need more data
* schannel: failed to decrypt data, need more data
{ [16384 bytes data]
* schannel: failed to decrypt data, need more data
{ [32768 bytes data]
* schannel: failed to decrypt data, need more data
* schannel: failed to decrypt data, need more data
{ [32768 bytes data]
* schannel: failed to decrypt data, need more data
* schannel: failed to decrypt data, need more data
{ [16384 bytes data]
* schannel: failed to decrypt data, need more data
* schannel: failed to decrypt data, need more data
{ [49152 bytes data]
* schannel: failed to decrypt data, need more data
{ [49152 bytes data]
* schannel: failed to decrypt data, need more data
{ [32768 bytes data]
* schannel: failed to decrypt data, need more data
{ [32768 bytes data]
* schannel: failed to decrypt data, need more data
{ [32768 bytes data]
* schannel: failed to decrypt data, need more data
{ [16384 bytes data]
* schannel: failed to decrypt data, need more data
{ [32768 bytes data]
* schannel: failed to decrypt data, need more data
{ [16384 bytes data]
* schannel: failed to decrypt data, need more data
{ [32768 bytes data]
* schannel: failed to decrypt data, need more data
{ [32768 bytes data]
* schannel: failed to decrypt data, need more data
{ [32768 bytes data]
* schannel: failed to decrypt data, need more data
* schannel: failed to decrypt data, need more data
{ [16384 bytes data]
* schannel: failed to decrypt data, need more data
{ [32768 bytes data]
* schannel: failed to decrypt data, need more data
* schannel: failed to decrypt data, need more data
{ [32768 bytes data]
* schannel: failed to decrypt data, need more data
{ [65536 bytes data]
* schannel: failed to decrypt data, need more data
{ [16384 bytes data]
* schannel: failed to decrypt data, need more data
{ [32768 bytes data]
* schannel: failed to decrypt data, need more data
* schannel: failed to decrypt data, need more data
{ [16384 bytes data]
* schannel: failed to decrypt data, need more data
{ [32768 bytes data]
* schannel: failed to decrypt data, need more data
{ [32768 bytes data]
* schannel: failed to decrypt data, need more data
* schannel: failed to decrypt data, need more data
{ [16384 bytes data]
* schannel: failed to decrypt data, need more data
* schannel: failed to decrypt data, need more data
{ [98304 bytes data]
* schannel: failed to decrypt data, need more data
{ [16384 bytes data]
* schannel: failed to decrypt data, need more data
* schannel: failed to decrypt data, need more data
{ [49152 bytes data]
* schannel: failed to decrypt data, need more data
{ [49152 bytes data]
* schannel: failed to decrypt data, need more data
{ [32768 bytes data]
* schannel: failed to decrypt data, need more data

This keeps going until you press Ctrl+C. It still downloads the file successfully (passes SHA1 check), but something’s definitely wrong here.

Turns out it was Fiddler running that caused the problem.

2 Likes