caddyserver / caddy

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

Panic when proxying: not a Flusher #1252

Closed ulrichSchreiner closed 7 years ago

ulrichSchreiner commented 7 years ago

(Are you asking for help with using Caddy? Please use our forum instead: https://forum.caddyserver.com. If you are filing a bug report, please answer the following questions. If your issue is not a bug report, you do not need to use this template. Either way, please consider donating if we've helped you. Thanks!)

1. What version of Caddy are you running (caddy -version)?

/ $ /usr/bin/caddy -version Caddy 0.9.3

2. What are you trying to do?

Proxy'ing request to a backend server

3. What is your entire Caddyfile?

myserver:443 {
  header /GUI Cache-Control "max-age=600"

  log / stdout "{remote} -  [{when}] \"{request}\" {status} {size} {latency}"

  gzip
  tls {
        max_certs 10
  }
  prometheus
  proxy / http://zope:8080/VirtualHostBase/https/myserver:443/sites/mysite/VirtualHostRoot {
    transparent
    max_fails 1
    fail_timeout 0s
    insecure_skip_verify
  }
}

i have multiple of this configs for different servers. all of them are identical except the backend-proxy-url.

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

Caddy runs inside a dockercontainer (alpine) with this command:

usr/bin/caddy -conf /etc/Caddyfile -agree -log stdout -port 80 -email ...

5. What did you expect to see?

Proxied requests

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

Nov 10 15:34:33 cebra-prod docker[15617]: panic: not a Flusher
Nov 10 15:34:33 cebra-prod docker[15617]: goroutine 334176 [running]:
Nov 10 15:34:33 cebra-prod docker[15617]: panic(0x9cf280, 0xc420176030)
Nov 10 15:34:33 cebra-prod docker[15617]:         /usr/local/go/src/runtime/panic.go:500 +0x1a1
Nov 10 15:34:33 cebra-prod docker[15617]: github.com/mholt/caddy/caddyhttp/httpserver.(*ResponseRecorder).Flush(0xc420182000)
Nov 10 15:34:33 cebra-prod docker[15617]:         /tmp/custombuild_7536_902763092/src/github.com/mholt/caddy/caddyhttp/httpserver/recorder.go:87 +0xda
Nov 10 15:34:33 cebra-prod docker[15617]: github.com/mholt/caddy/caddyhttp/proxy.(*maxLatencyWriter).flushLoop(0xc42037a480)
Nov 10 15:34:33 cebra-prod docker[15617]:         /tmp/custombuild_7536_902763092/src/github.com/mholt/caddy/caddyhttp/proxy/reverseproxy.go:400 +0x156
Nov 10 15:34:33 cebra-prod docker[15617]: created by github.com/mholt/caddy/caddyhttp/proxy.(*ReverseProxy).copyResponse
Nov 10 15:34:33 cebra-prod docker[15617]:         /tmp/custombuild_7536_902763092/src/github.com/mholt/caddy/caddyhttp/proxy/reverseproxy.go:247 +0x2e1

7. How can someone who is starting from scratch reproduce this behavior as minimally as possible?

I don't know. this happens sometimes once or two times a week. not regularly.

mholt commented 7 years ago

Does it still happen if you take out the header directive?

ulrichSchreiner commented 7 years ago

hard to say as it is not really reproducable :-). but i changed my playbook and rolled out a new version of the file. and i will set a reminder to give you feedback in about a week (if nothing happens). or earlier :-)

mholt commented 7 years ago

Great, thanks!

ulrichSchreiner commented 7 years ago

hi,

the server is running without problems since a week now. normally i had this issue at least once a week so i think the removal of the header helped. well it is not a hard proof but an indication.

i will close the issue. it the error happens, i will reopen it.

mholt commented 7 years ago

Sounds good, since I think it is fixed on master if it indeed is the header directive. https://github.com/mholt/caddy/commit/14500d8204c806edc69daa1725df7c68aa6f6347