1. The problem I’m having:
I am attempting to configure Caddy v2 in the following scenario and need assistance:
I am deploying a docker container using Portainer for a web tool (teslamate) that has two components, each accessible using a different port. The stack name will be “teslamate” and it will be accessed as https://teslamate.example.com which needs port 4000 as well as https://teslamate.example.com/grafana which needs port 3000
Caddy to handle SSL from Let’s Encrypt…
Not sure what the proper configuration should look like, I made a config but need some input…
2. Error messages and/or full log output:
When I access https://tm.example.com from the LAN nothing else is rendered and Caddy logs show this error:
ERR | ts=1718561624.8732326 logger=http.log.error msg=tls: first record does not look like a TLS handshake request={"remote_ip":"192.168.1.199","remote_port":"65252","client_ip":"192.168.1.199","proto":"HTTP/2.0","method":"GET","host":"tm.example.com","uri":"/","headers":{"Accept":["text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8"],"Sec-Fetch-Mode":["navigate"],"Cookie":["REDACTED"],"Authorization":["REDACTED"],"Accept-Language":["en-US,en;q=0.8"],"Sec-Fetch-User":["?1"],"Accept-Encoding":["gzip, deflate, br, zstd"],"Priority":["u=0, i"],"Cache-Control":["max-age=0"],"Sec-Ch-Ua":["\"Not/A)Brand\";v=\"8\", \"Chromium\";v=\"126\", \"Brave\";v=\"126\""],"Sec-Ch-Ua-Mobile":["?0"],"User-Agent":["Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/126.0.0.0 Safari/537.36"],"Sec-Fetch-Site":["none"],"Sec-Fetch-Dest":["document"],"Sec-Ch-Ua-Platform":["\"macOS\""],"Upgrade-Insecure-Requests":["1"],"Sec-Gpc":["1"]},"tls":{"resumed":true,"version":772,"cipher_suite":4865,"proto":"h2","server_name":"tm.example.com"}} duration=0.000985858 status=502 err_id=bgskc9nkg err_trace=reverseproxy.statusError (reverseproxy.go:1269)
3. Caddy version:
caddy v2.8.4
4. How I installed and ran Caddy:
a. System environment:
Ubuntu Server
Docker
Docker compose v2
Portainer
b. Command:
n/a
c. Service/unit/compose file:
n/a
d. My complete Caddy config:
tm.example.com {
handle_path /grafana* {
encode gzip
basic_auth / {
gf-admin $23ihnqbeocbqebfihbadfvnbsrgbsfb
}
reverse_proxy {
to https://teslamate:3000
transport http {
tls
tls_insecure_skip_verify
}
}
}
handle {
encode gzip
basic_auth / {
tm-admin $vweonqvbqvuabworhuqfvjanefjn
}
reverse_proxy {
to https://teslamate:4000
transport http {
tls
tls_insecure_skip_verify
}
}
}
}
5. Links to relevant resources:
Separate case on same issue opened on Teslamate forum as well: