Caddy returns blank page always

1. Caddy version (caddy version):

(devel)

2. How I run Caddy:

Under termux, android 11, lineageos. Caddy from official termux repos

a. System environment:

Termux

b. Command:

caddy run --config Caddyfile

c. Service/unit/compose file:

None

d. My complete Caddyfile or JSON config:

http://localhost:8080 {
	root * /data/data/com.termux/files/home
	file_server browse
}

3. The problem I’m having:

Cant view any files, even index.html, all reuquest return a blank oage

4. Error messages and/or full log output:

Log:

2021/10/24 08:00:58.684 INFO    using provided configuration    {"config_file": "Caddyfile", "config_adapter": ""}
2021/10/24 08:00:58.700 INFO    admin   admin endpoint started  {"address": "tcp/localhost:2019", "enforce_origin": false, "origins": ["localhost:2019", "[::1]:2019", "127.0.0.1:2019"]}
2021/10/24 08:00:58.705 INFO    tls.cache.maintenance   started background certificate maintenance        {"cache": "0x4000628000"}
2021/10/24 08:00:58.707 INFO    tls     cleaning storage unit   {"description": "FileStorage:/data/data/com.termux/files/home/caddy"}
2021/10/24 08:00:58.708 INFO    tls     finished cleaning storage units
2021/10/24 08:00:58.714 INFO    autosaved config (load with --resume flag){"file": "/data/data/com.termux/files/home/.config/caddy/autosave.json"}
2021/10/24 08:00:58.714 INFO    serving initial configuration

Curl output:

~ $ curl -v 127.0.0.1:8080
*   Trying 127.0.0.1:8080...
* Connected to 127.0.0.1 (127.0.0.1) port 8080 (#0)
> GET / HTTP/1.1
> Host: 127.0.0.1:8080
> User-Agent: curl/7.79.1
> Accept: */*
>
* Mark bundle as not supporting multiuse
< HTTP/1.1 200 OK
< Server: Caddy
< Date: Sun, 24 Oct 2021 08:08:11 GMT
< Content-Length: 0
<
* Connection #0 to host 127.0.0.1 left intact

5. What I already tried:

Adding file_server to Caddyfile, since apparently not adding that causes blank pages, but it happens for me rrgardless.
I also tried this on desktop ubuntu, and the problem exists(with the same config)

6. Links to relevant resources:

You used localhost as your site address, so Caddy is waiting for requests for the hostname localhost to serve the content, as configured. But you requested 127.0.0.1, which is not localhost (resolves to the same IP, but many domains can resolve to the same IP address).

Either use :8080 as your site address to accept HTTP requests for any hostname, or make your request with curl -v localhost:8080 instead.

The result of a blank page is Caddy’s default behaviour for the request not having been handled by any request handlers. Technically the site address is a host matcher, so if it doesn’t match, it fall through unhandled and you end up with an empty response. Caddy essentially worked as configured.

2 Likes

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