caddyserver / caddy

Fast and extensible multi-platform HTTP/1-2-3 web server with automatic HTTPS
https://caddyserver.com
Apache License 2.0
57.51k stars 4.01k forks source link

Problem with HTTP request #2858

Closed nginx-x closed 4 years ago

nginx-x commented 4 years ago

1. Which version of Caddy are you using (caddy -version)?

v2.0.0-beta8 h1:eNVaQrLCP9ZpY7zqeq5kI/cYLjJ8XGyzA1MxvpYX1vI=

I downloaded "caddy2_beta8_linux_amd64" from Github releases page.

2. What are you trying to do?

Just testing Caddy 2 beta, using documentation, and trying to make a connection

3. What is your Caddyfile?

config is as follows: { "apps": { "http": { "servers": { "myserver": { "listen": [":80"], "routes": [ { "handle": [{ "handler": "file_server", "root": "/home/html" }] } ] } } } } }

and written into /etc/caddy/config.json

I did copy & paste and just edited path from your documentation https://github.com/caddyserver/caddy/wiki/v2:-Config-from-Scratch here.

4. How did you run Caddy (give the full command and describe the execution environment)?

I ran this program on openSUSE Tumbleweed(amd64), using command "caddy start --config /etc/caddy/config.json".

5. Please paste any relevant HTTP request(s) here.

Nope, just through web browser.

6. What did you expect to see?

Just no error, and working web page.

7. What did you see instead (give full error messages and/or log)?

In server side : 2019/11/04 04:59:48 http: panic serving :3664: runtime error: invalid memory address or nil pointer dereference goroutine 28 [running]: net/http.(conn).serve.func1(0xc0001d8460) /usr/local/go/src/net/http/server.go:1767 +0x139 panic(0xcc2ae0, 0x151cdf0) /usr/local/go/src/runtime/panic.go:679 +0x1b2 github.com/caddyserver/caddy/v2/modules/caddyhttp.errLogValues(0xf02660, 0xc000092540, 0xc0002ce000, 0xc0000ec400, 0xc00026c000, 0x1, 0x4, 0xf02660) /Users/matt/Dev/pkg/mod/github.com/caddyserver/caddy/v2@v2.0.0-beta8/modules/caddyhttp/server.go:371 +0xc3 github.com/caddyserver/caddy/v2/modules/caddyhttp.(Server).ServeHTTP(0xc000220ea0, 0xf11d00, 0xc0002ce000, 0xc0000ec400) /Users/matt/Dev/pkg/mod/github.com/caddyserver/caddy/v2@v2.0.0-beta8/modules/caddyhttp/server.go:144 +0x7a0 net/http.serverHandler.ServeHTTP(0xc00017e2a0, 0xf11d00, 0xc0002ce000, 0xc0000ec100) /usr/local/go/src/net/http/server.go:2802 +0xa4 net/http.(conn).serve(0xc0001d8460, 0xf14980, 0xc0000923c0) /usr/local/go/src/net/http/server.go:1890 +0x875 created by net/http.(Server).Serve /usr/local/go/src/net/http/server.go:2927 +0x38e 2019/11/04 04:59:48 http: panic serving :3665: runtime error: invalid memory address or nil pointer dereference goroutine 7 [running]: net/http.(conn).serve.func1(0xc0000b8fa0) /usr/local/go/src/net/http/server.go:1767 +0x139 panic(0xcc2ae0, 0x151cdf0) /usr/local/go/src/runtime/panic.go:679 +0x1b2 github.com/caddyserver/caddy/v2/modules/caddyhttp.errLogValues(0xf02660, 0xc0002e6180, 0xc000300000, 0xc0002ee200, 0xc00026c000, 0x1, 0x4, 0xf02660) /Users/matt/Dev/pkg/mod/github.com/caddyserver/caddy/v2@v2.0.0-beta8/modules/caddyhttp/server.go:371 +0xc3 github.com/caddyserver/caddy/v2/modules/caddyhttp.(Server).ServeHTTP(0xc000220ea0, 0xf11d00, 0xc000300000, 0xc0002ee200) /Users/matt/Dev/pkg/mod/github.com/caddyserver/caddy/v2@v2.0.0-beta8/modules/caddyhttp/server.go:144 +0x7a0 net/http.serverHandler.ServeHTTP(0xc00017e2a0, 0xf11d00, 0xc000300000, 0xc0002ee000) /usr/local/go/src/net/http/server.go:2802 +0xa4 net/http.(conn).serve(0xc0000b8fa0, 0xf14980, 0xc0002e6000) /usr/local/go/src/net/http/server.go:1890 +0x875 created by net/http.(Server).Serve /usr/local/go/src/net/http/server.go:2927 +0x38e 2019/11/04 04:59:48 http: panic serving :3666: runtime error: invalid memory address or nil pointer dereference goroutine 8 [running]: net/http.(conn).serve.func1(0xc0000b9040) /usr/local/go/src/net/http/server.go:1767 +0x139 panic(0xcc2ae0, 0x151cdf0) /usr/local/go/src/runtime/panic.go:679 +0x1b2 github.com/caddyserver/caddy/v2/modules/caddyhttp.errLogValues(0xf02660, 0xc0000926c0, 0xc0002ce0e0, 0xc0000ec700, 0xc00026c000, 0x1, 0x4, 0xf02660) /Users/matt/Dev/pkg/mod/github.com/caddyserver/caddy/v2@v2.0.0-beta8/modules/caddyhttp/server.go:371 +0xc3 github.com/caddyserver/caddy/v2/modules/caddyhttp.(Server).ServeHTTP(0xc000220ea0, 0xf11d00, 0xc0002ce0e0, 0xc0000ec700) /Users/matt/Dev/pkg/mod/github.com/caddyserver/caddy/v2@v2.0.0-beta8/modules/caddyhttp/server.go:144 +0x7a0 net/http.serverHandler.ServeHTTP(0xc00017e2a0, 0xf11d00, 0xc0002ce0e0, 0xc0000ec500) /usr/local/go/src/net/http/server.go:2802 +0xa4 net/http.(conn).serve(0xc0000b9040, 0xf14980, 0xc000092580) /usr/local/go/src/net/http/server.go:1890 +0x875 created by net/http.(Server).Serve /usr/local/go/src/net/http/server.go:2927 +0x38e 2019/11/04 04:59:49 http: panic serving :3667: runtime error: invalid memory address or nil pointer dereference goroutine 10 [running]: net/http.(conn).serve.func1(0xc0000b90e0) /usr/local/go/src/net/http/server.go:1767 +0x139 panic(0xcc2ae0, 0x151cdf0) /usr/local/go/src/runtime/panic.go:679 +0x1b2 github.com/caddyserver/caddy/v2/modules/caddyhttp.errLogValues(0xf02660, 0xc0002e6300, 0xc0003000e0, 0xc0002ee500, 0xc00026c000, 0x1, 0x4, 0xf02660) /Users/matt/Dev/pkg/mod/github.com/caddyserver/caddy/v2@v2.0.0-beta8/modules/caddyhttp/server.go:371 +0xc3 github.com/caddyserver/caddy/v2/modules/caddyhttp.(Server).ServeHTTP(0xc000220ea0, 0xf11d00, 0xc0003000e0, 0xc0002ee500) /Users/matt/Dev/pkg/mod/github.com/caddyserver/caddy/v2@v2.0.0-beta8/modules/caddyhttp/server.go:144 +0x7a0 net/http.serverHandler.ServeHTTP(0xc00017e2a0, 0xf11d00, 0xc0003000e0, 0xc0002ee300) /usr/local/go/src/net/http/server.go:2802 +0xa4 net/http.(conn).serve(0xc0000b90e0, 0xf14980, 0xc0002e61c0) /usr/local/go/src/net/http/server.go:1890 +0x875 created by net/http.(Server).Serve /usr/local/go/src/net/http/server.go:2927 +0x38e 2019/11/04 04:59:49 http: panic serving :3668: runtime error: invalid memory address or nil pointer dereference goroutine 29 [running]: net/http.(conn).serve.func1(0xc0001d8500) /usr/local/go/src/net/http/server.go:1767 +0x139 panic(0xcc2ae0, 0x151cdf0) /usr/local/go/src/runtime/panic.go:679 +0x1b2 github.com/caddyserver/caddy/v2/modules/caddyhttp.errLogValues(0xf02660, 0xc0001bfe00, 0xc00017e540, 0xc000194800, 0xc00026c000, 0x1, 0x4, 0xf02660) /Users/matt/Dev/pkg/mod/github.com/caddyserver/caddy/v2@v2.0.0-beta8/modules/caddyhttp/server.go:371 +0xc3 github.com/caddyserver/caddy/v2/modules/caddyhttp.(Server).ServeHTTP(0xc000220ea0, 0xf11d00, 0xc00017e540, 0xc000194800) /Users/matt/Dev/pkg/mod/github.com/caddyserver/caddy/v2@v2.0.0-beta8/modules/caddyhttp/server.go:144 +0x7a0 net/http.serverHandler.ServeHTTP(0xc00017e2a0, 0xf11d00, 0xc00017e540, 0xc000194600) /usr/local/go/src/net/http/server.go:2802 +0xa4 net/http.(conn).serve(0xc0001d8500, 0xf14980, 0xc0001bfc80) /usr/local/go/src/net/http/server.go:1890 +0x875 created by net/http.(Server).Serve /usr/local/go/src/net/http/server.go:2927 +0x38e 2019/11/04 04:59:50 http: panic serving :3669: runtime error: invalid memory address or nil pointer dereference goroutine 51 [running]: net/http.(conn).serve.func1(0xc00035c000) /usr/local/go/src/net/http/server.go:1767 +0x139 panic(0xcc2ae0, 0x151cdf0) /usr/local/go/src/runtime/panic.go:679 +0x1b2 github.com/caddyserver/caddy/v2/modules/caddyhttp.errLogValues(0xf02660, 0xc0001bff00, 0xc00017e620, 0xc000194a00, 0xc00026c000, 0x1, 0x4, 0xf02660) /Users/matt/Dev/pkg/mod/github.com/caddyserver/caddy/v2@v2.0.0-beta8/modules/caddyhttp/server.go:371 +0xc3 github.com/caddyserver/caddy/v2/modules/caddyhttp.(Server).ServeHTTP(0xc000220ea0, 0xf11d00, 0xc00017e620, 0xc000194a00) /Users/matt/Dev/pkg/mod/github.com/caddyserver/caddy/v2@v2.0.0-beta8/modules/caddyhttp/server.go:144 +0x7a0 net/http.serverHandler.ServeHTTP(0xc00017e2a0, 0xf11d00, 0xc00017e620, 0xc0002ee600) /usr/local/go/src/net/http/server.go:2802 +0xa4 net/http.(conn).serve(0xc00035c000, 0xf14980, 0xc0002e6340) /usr/local/go/src/net/http/server.go:1890 +0x875 created by net/http.(Server).Serve /usr/local/go/src/net/http/server.go:2927 +0x38e 2019/11/04 04:59:50 http: panic serving :3670: runtime error: invalid memory address or nil pointer dereference goroutine 52 [running]: net/http.(conn).serve.func1(0xc00035c0a0) /usr/local/go/src/net/http/server.go:1767 +0x139 panic(0xcc2ae0, 0x151cdf0) /usr/local/go/src/runtime/panic.go:679 +0x1b2 github.com/caddyserver/caddy/v2/modules/caddyhttp.errLogValues(0xf02660, 0xc0002e6500, 0xc0003001c0, 0xc0002ee900, 0xc00026c000, 0x1, 0x4, 0xf02660) /Users/matt/Dev/pkg/mod/github.com/caddyserver/caddy/v2@v2.0.0-beta8/modules/caddyhttp/server.go:371 +0xc3 github.com/caddyserver/caddy/v2/modules/caddyhttp.(Server).ServeHTTP(0xc000220ea0, 0xf11d00, 0xc0003001c0, 0xc0002ee900) /Users/matt/Dev/pkg/mod/github.com/caddyserver/caddy/v2@v2.0.0-beta8/modules/caddyhttp/server.go:144 +0x7a0 net/http.serverHandler.ServeHTTP(0xc00017e2a0, 0xf11d00, 0xc0003001c0, 0xc0002ee700) /usr/local/go/src/net/http/server.go:2802 +0xa4 net/http.(conn).serve(0xc00035c0a0, 0xf14980, 0xc0002e63c0) /usr/local/go/src/net/http/server.go:1890 +0x875 created by net/http.(Server).Serve /usr/local/go/src/net/http/server.go:2927 +0x38e 2019/11/04 04:59:51 http: panic serving :3671: runtime error: invalid memory address or nil pointer dereference goroutine 54 [running]: net/http.(conn).serve.func1(0xc00035c140) /usr/local/go/src/net/http/server.go:1767 +0x139 panic(0xcc2ae0, 0x151cdf0) /usr/local/go/src/runtime/panic.go:679 +0x1b2 github.com/caddyserver/caddy/v2/modules/caddyhttp.errLogValues(0xf02660, 0xc000092840, 0xc0002ce1c0, 0xc0000eca00, 0xc00026c000, 0x1, 0x4, 0xf02660) /Users/matt/Dev/pkg/mod/github.com/caddyserver/caddy/v2@v2.0.0-beta8/modules/caddyhttp/server.go:371 +0xc3 github.com/caddyserver/caddy/v2/modules/caddyhttp.(Server).ServeHTTP(0xc000220ea0, 0xf11d00, 0xc0002ce1c0, 0xc0000eca00) /Users/matt/Dev/pkg/mod/github.com/caddyserver/caddy/v2@v2.0.0-beta8/modules/caddyhttp/server.go:144 +0x7a0 net/http.serverHandler.ServeHTTP(0xc00017e2a0, 0xf11d00, 0xc0002ce1c0, 0xc0000ec800) /usr/local/go/src/net/http/server.go:2802 +0xa4 net/http.(conn).serve(0xc00035c140, 0xf14980, 0xc000092700) /usr/local/go/src/net/http/server.go:1890 +0x875 created by net/http.(Server).Serve /usr/local/go/src/net/http/server.go:2927 +0x38e 2019/11/04 04:59:51 http: panic serving :3672: runtime error: invalid memory address or nil pointer dereference goroutine 12 [running]: net/http.(conn).serve.func1(0xc0000b9180) /usr/local/go/src/net/http/server.go:1767 +0x139 panic(0xcc2ae0, 0x151cdf0) /usr/local/go/src/runtime/panic.go:679 +0x1b2 github.com/caddyserver/caddy/v2/modules/caddyhttp.errLogValues(0xf02660, 0xc0000929c0, 0xc0002ce2a0, 0xc0000ecd00, 0xc00026c000, 0x1, 0x4, 0xf02660) /Users/matt/Dev/pkg/mod/github.com/caddyserver/caddy/v2@v2.0.0-beta8/modules/caddyhttp/server.go:371 +0xc3 github.com/caddyserver/caddy/v2/modules/caddyhttp.(Server).ServeHTTP(0xc000220ea0, 0xf11d00, 0xc0002ce2a0, 0xc0000ecd00) /Users/matt/Dev/pkg/mod/github.com/caddyserver/caddy/v2@v2.0.0-beta8/modules/caddyhttp/server.go:144 +0x7a0 net/http.serverHandler.ServeHTTP(0xc00017e2a0, 0xf11d00, 0xc0002ce2a0, 0xc0000ecb00) /usr/local/go/src/net/http/server.go:2802 +0xa4 net/http.(conn).serve(0xc0000b9180, 0xf14980, 0xc000092880) /usr/local/go/src/net/http/server.go:1890 +0x875 created by net/http.(Server).Serve /usr/local/go/src/net/http/server.go:2927 +0x38e 2019/11/04 04:59:52 http: panic serving :3673: runtime error: invalid memory address or nil pointer dereference goroutine 32 [running]: net/http.(conn).serve.func1(0xc0001d85a0) /usr/local/go/src/net/http/server.go:1767 +0x139 panic(0xcc2ae0, 0x151cdf0) /usr/local/go/src/runtime/panic.go:679 +0x1b2 github.com/caddyserver/caddy/v2/modules/caddyhttp.errLogValues(0xf02660, 0xc0003a2080, 0xc00017e700, 0xc000194d00, 0xc00026c000, 0x1, 0x4, 0xf02660) /Users/matt/Dev/pkg/mod/github.com/caddyserver/caddy/v2@v2.0.0-beta8/modules/caddyhttp/server.go:371 +0xc3 github.com/caddyserver/caddy/v2/modules/caddyhttp.(Server).ServeHTTP(0xc000220ea0, 0xf11d00, 0xc00017e700, 0xc000194d00) /Users/matt/Dev/pkg/mod/github.com/caddyserver/caddy/v2@v2.0.0-beta8/modules/caddyhttp/server.go:144 +0x7a0 net/http.serverHandler.ServeHTTP(0xc00017e2a0, 0xf11d00, 0xc00017e700, 0xc000194b00) /usr/local/go/src/net/http/server.go:2802 +0xa4 net/http.(conn).serve(0xc0001d85a0, 0xf14980, 0xc0001bff40) /usr/local/go/src/net/http/server.go:1890 +0x875 created by net/http.(Server).Serve /usr/local/go/src/net/http/server.go:2927 +0x38e

In client side, Firefox returned : The connection was reset

The connection to the server was reset while the page was loading.

The site could be temporarily unavailable or too busy. Try again in a few moments.
If you are unable to load any pages, check your computer’s network connection.
If your computer or network is protected by a firewall or proxy, make sure that Firefox is permitted to access the Web.

8. Why is this a bug, and how do you think this should be fixed?

I found that beta 6 is fine with my current configuration. so I think it's a bug.

9. What are you doing to work around the problem in the meantime?

Just use beta 6, instead of beta 8.

10. Please link to any related issues, pull requests, and/or discussion.

Bonus: What do you use Caddy for? Why did you choose Caddy?

Just want to know that if I can replace nginx with Caddy in production level, but I think it's too complicated :0 I'm not a fan of new caddy v2 configuration style. Actually the configuration is the most devastated part for me 😭 😭

mholt commented 4 years ago

Thanks for the report!

I believe this has already been fixed on master :) Please build from source and try again and let us know how it goes!

mholt commented 4 years ago

I'm not a fan of new caddy v2 configuration style. Actually the configuration is the most devastated part for me 😭 😭

Can you explain what is "devastated" about it? What would you like instead?

(PS. Thank you very much for trying Caddy 2! Don't give up on it yet, I haven't gotten around to finishing the "easy to use" part)

nginx-x commented 4 years ago

First of all, thanks for your reply, and sorry to bother you with an already fixed issue (I just found issue 2845).

And also, It's good to use a Caddyfile instead of writing JSON line-by-line. Actually I LOVE your Caddyfile implementation. It's very short and easy way to write a configuration.

Thanks for your awesome software. I'll just wait for next beta binary for the bug fixes.

mholt commented 4 years ago

@delphixe4 Thank you for the reply! (Too many people disappear after "This is hard" and I don't know what they are thinking)

I'm really glad you like the Caddyfile, it's one of Caddy's best features. And we're keeping it in Caddy 2 -- with optional improvements!

I have good news too:

But I found that this is somewhat confusing that describing Caddyfile method and raw json format method in one page(https://github.com/caddyserver/caddy/wiki/v2:-Documentation), at least for beginners.

You are right! That page is temporary until we stand up our full documentation site for Caddy 2. That'll come towards the end of the beta versions or in the release candidate phase, later this year. Development has just been moving so quickly.

I think describing Caddyfile config as a default and presenting raw JSON config as an additional matter is maybe more intuitive. (Note that I am not familiar with Caddy for now)

I agree with you on this, too. Our new homepage tries to do this by introducing you to the Caddyfile first, then the REST API / JSON config later.

And I think suggesting a very long config example like nginx does, is good for users to help understanding configuration by 1 to 1 matching with documentation.

Hmm, okay! Do you have a link to nginx's example that you're referring to? Is it this one? https://www.nginx.com/resources/wiki/start/topics/examples/full/

nginx-x commented 4 years ago

Thanks for your comment!

Yes, I meant that nginx.conf example. They present some global configuration, whole structure of configuration file and basic example of server usage.

And lack of "shut up and follow" tutorial (like https://www.howtoforge.com/tutorial/ubuntu-caddy-web-server-installation/) is little minus but I think it's a matter of time. Actually, I will write my own version if I manage to operate a Caddy 2 server. 👍

Anyway your comments really helped me a lot. thanks again!

mholt commented 4 years ago

Fixed in https://github.com/caddyserver/caddy/commit/fb06c041c4be4eb32f18d54e8e7feff8dd76b0e9

Please try the latest! Watch for beta 9 going out today.