Fileserver does not show the browse page

1. The problem I’m having:

I try to use the file_server with the latest caddy version. When I run caddy and make a call via curl or Chrome is the response an empty page. I’m pretty sure that I miss something important therefore I seek here for help and the eyeopener :slight_smile: , thank you for your help.

2. Error messages and/or full log output:

alex@alex-TUXEDO-Book-XP1511 on Di Mai 09 at 21:58:35 /datadisk/git-repos/caddyv2-upload/docker-files/opt/webroot # APPPORT=8888 ~/Downloads/caddy_linux_amd64 run --config config/Caddyfile-test 
2023/05/09 19:58:36.166	INFO	using provided configuration	{"config_file": "config/Caddyfile-test", "config_adapter": ""}
2023/05/09 19:58:36.167	WARN	admin	admin endpoint disabled
2023/05/09 19:58:36.168	WARN	http	automatic HTTPS is completely disabled for server	{"server_name": "srv0"}
2023/05/09 19:58:36.168	INFO	tls.cache.maintenance	started background certificate maintenance	{"cache": "0xc0005482a0"}
2023/05/09 19:58:36.168	INFO	tls	cleaning storage unit	{"description": "FileStorage:/home/alex/.local/share/caddy"}
2023/05/09 19:58:36.168	INFO	tls	finished cleaning storage units
2023/05/09 19:58:36.168	DEBUG	http	starting server loop	{"address": "[::]:8888", "tls": false, "http3": false}
2023/05/09 19:58:36.168	INFO	http.log	server running	{"name": "srv0", "protocols": ["h1", "h2", "h3"]}
2023/05/09 19:58:36.168	INFO	autosaved config (load with --resume flag)	{"file": "/home/alex/.config/caddy/autosave.json"}
2023/05/09 19:58:36.168	INFO	serving initial configuration

# Request via Curl
2023/05/09 19:58:41.744	INFO	http.log.access	handled request	{"request": {"remote_ip": "127.0.0.1", "remote_port": "37802", "proto": "HTTP/1.1", "method": "GET", "host": "127.0.0.1:8888", "uri": "/", "headers": {"User-Agent": ["curl/7.81.0"], "Accept": ["*/*"]}}, "user_id": "", "duration": 0.000002025, "size": 0, "status": 0, "resp_headers": {"Server": ["Caddy"]}}

Curl output

curl -v http://127.0.0.1:8888/
*   Trying 127.0.0.1:8888...
* Connected to 127.0.0.1 (127.0.0.1) port 8888 (#0)
> GET / HTTP/1.1
> Host: 127.0.0.1:8888
> User-Agent: curl/7.81.0
> Accept: */*
> 
* Mark bundle as not supporting multiuse
< HTTP/1.1 200 OK
< Server: Caddy
< Date: Tue, 09 May 2023 20:25:55 GMT
< Content-Length: 0
< 
* Connection #0 to host 127.0.0.1 left intact

3. Caddy version:

~/Downloads/caddy_linux_amd64 version
v2.6.4 h1:2hwYqiRwk1tf3VruhMpLcYTg+11fCdr8S3jhNAdnPy8=

4. How I installed and ran Caddy:

Just downloaded via Download Caddy

a. System environment:

I start it via CLI run

b. Command:

APPPORT=8888 ~/Downloads/caddy_linux_amd64 run --config config/Caddyfile-test 

c. Service/unit/compose file:

I start it via CLI run

d. My complete Caddy config:

{
	http_port {$APPPORT}
	https_port 0
	auto_https off
	admin off
	log {
		level DEBUG
	}
}

localhost:{$APPPORT} {
	root .

	file_server browse
	templates

	log {
		output file access.log
	}
}

5. Links to relevant resources:

I’m debugging the issue in Response template doesn't get returned on successful upload · Issue #12 · git001/caddyv2-upload · GitHub in my module and was a little bit confused that the simple file_server does not show the browse page.

FYI, you can remove:

https_port 0
root .

They are doing nothing for you. :slight_smile:

What are the contents of your current directory?

Thank you. I have now comment the both directives.

That’s my directory listing

alex@alex-TUXEDO-Book-XP1511 on Di Mai 09 at 22:49:50 /datadisk/git-repos/caddyv2-upload/docker-files/opt/webroot # ls -la
total 32
drwxrwxr-x 6 alex alex 4096 Mai  9 17:00 .
drwxrwxr-x 3 alex alex 4096 Mai  3  2022 ..
-rw------- 1 alex alex 6619 Mai  9 17:01 access.log
drwxrwxr-x 2 alex alex 4096 Mai  9 17:36 config
drwxrwxr-x 2 alex alex 4096 Mai  3  2022 data
drwxrwxr-x 2 alex alex 4096 Aug 20  2022 templates
drwxr-xr-x 2 alex alex 4096 Mai  9 17:03 upload

Thanks, looks fine.

Duh, my bad – the request is sending a Host header of 127.0.0.1 and not localhost. So you need to use the same IP or domain as in your config file.

1 Like

Thank you @matt I know that was as simple stuipd mistake from me.
The response looks now like this.

curl -v http://localhost:8888/ -o /dev/null 
*   Trying 127.0.0.1:8888...
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0* Connected to localhost (127.0.0.1) port 8888 (#0)
> GET / HTTP/1.1
> Host: localhost:8888
> User-Agent: curl/7.81.0
> Accept: */*
> 
* Mark bundle as not supporting multiuse
< HTTP/1.1 200 OK
< Content-Length: 15285
< Content-Type: text/html; charset=utf-8
< Server: Caddy
< Date: Tue, 09 May 2023 21:20:20 GMT
< 
{ [3962 bytes data]
100 15285  100 15285    0     0   9.8M      0 --:--:-- --:--:-- --:--:-- 14.5M
* Connection #0 to host localhost left intact

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