Caddy: Panic rather than 404 if no log directive specified

Created on 11 Apr 2020  路  3Comments  路  Source: caddyserver/caddy

Version

$ ./caddy version
v2.0.0-rc.2 h1:7NOaxYrsnQ5D3rcLGn2UnLZHLfBpgrfM/JNTLhjCJ1c=

Caddyfile that causes panic

http://localhost:8080 {
    root * /home/nathanlcarlson
    file_server
}

Start:

./caddy run -config Caddyfile

Tested with curl:

$ curl -v localhost:8080/doesnotexist
* About to connect() to localhost port 8080 (#0)
*   Trying ::1...
* Connected to localhost (::1) port 8080 (#0)
> GET /doesnotexist HTTP/1.1
> User-Agent: curl/7.29.0
> Host: localhost:8080
> Accept: */*
> 
* Empty reply from server
* Connection #0 to host localhost left intact
curl: (52) Empty reply from server

Panic output from Caddy:

[timestamp] http: panic serving [::1]:[port]: runtime error: invalid memory address or nil pointer dereference
goroutine 36 [running]:
net/http.(*conn).serve.func1(0xc0001480a0)
    net/http/server.go:1772 +0x139
panic(0x144d380, 0x2470800)
    runtime/panic.go:975 +0x3e3
github.com/caddyserver/caddy/v2/modules/caddyhttp.(*Server).ServeHTTP(0xc0002dec60, 0x192e2e0, 0xc00015e000, 0xc0008ae600)
    github.com/caddyserver/caddy/[email protected]/modules/caddyhttp/server.go:203 +0x932
net/http.serverHandler.ServeHTTP(0xc0008ce380, 0x192e2e0, 0xc00015e000, 0xc0008ae400)
    net/http/server.go:2807 +0xa3
net/http.(*conn).serve(0xc0001480a0, 0x19334e0, 0xc00014c080)
    net/http/server.go:1895 +0x86c
created by net/http.(*Server).Serve
    net/http/server.go:2933 +0x35c

Caddyfile that returns (expected?) 404 result

http://localhost:8080 {
    root * /home/nathanlcarlson
    log
    file_server
}

curl:

$ curl -v localhost:8080/doesnotexist
* About to connect() to localhost port 8080 (#0)
*   Trying ::1...
* Connected to localhost (::1) port 8080 (#0)
> GET /doesnotexist HTTP/1.1
> User-Agent: curl/7.29.0
> Host: localhost:8080
> Accept: */*
> 
< HTTP/1.1 404 Not Found
< Server: Caddy
< Date: Fri, 10 Apr 2020 23:25:03 GMT
< Content-Length: 0
< 
* Connection #0 to host localhost left intact

Caddy 404:

[timestamp] ERROR   http.log.access handled request {"request": {"method": "GET", "uri": "/doesnotexist", "proto": "HTTP/1.1", "remote_addr": "[::1]:[port]", "host": "localhost:8080", "headers": {"Accept": ["*/*"], "User-Agent": ["curl/7.29.0"]}}, "common_log": "::1 - - [timestamp] \"GET /doesnotexist HTTP/1.1\" 404 0", "latency": 0.000119923, "size": 0, "status": 404, "resp_headers": {"Server": ["Caddy"]}}
duplicate

Most helpful comment

Hi, the issue I was experiencing, as detailed above, appears to be resolved by this. I'll be sure to report any other issues encountered. Thanks!

All 3 comments

I'm pretty sure this is a duplicate of https://github.com/caddyserver/caddy/issues/3248, this was a regression in RC2 which has already been fixed in master. Please try the latest build artifact https://github.com/caddyserver/caddy/actions/runs/75592323

If it doesn't work for you with the latest build, I'll gladly reopen this.

Hi, the issue I was experiencing, as detailed above, appears to be resolved by this. I'll be sure to report any other issues encountered. Thanks!

Great, thank you! Sorry for the trouble. Glad you're using it before the final release :)

Was this page helpful?
0 / 5 - 0 ratings

Related issues

billop picture billop  路  3Comments

lorddaedra picture lorddaedra  路  3Comments

la0wei picture la0wei  路  3Comments

mschneider82 picture mschneider82  路  3Comments

xfzka picture xfzka  路  3Comments