I wanted to upgrade portainer recently from 1.x to 2.x but now have a certificate issue. Inbound traffic is loadbalanced with traefik and attempting to load the portainer UI I get these messages:
traefik: traefik_traefik.1.68d2njton45p@swarm01 | time="2022-12-13T14:35:32Z" level=debug msg="'500 Internal Server Error' caused by: x509: certificate is valid for 0.0.0.0, not 10.0.21.178"
portainer: portainer_portainer.1.2f95iz88q99v@swarm01 | {"time":1670942132,"message":"http: TLS handshake error from 10.0.21.175:59844: remote error: tls: bad certificate"}
It's run in a secure and private network, so I don't mind not having https. On the flip-side this was been working perfectly for almost 3 years now, and it is only since the portainer upgrade that this problem happened. Ideally I would just regenerate the certificates, I will have plain http as a back-up.
The problem might be that Traefik terminates TLS, I don't think Portainer can create a signed cert. And when using a custom unsigned cert, you need to use insecureskipverify.
The compose file here Install Portainer with Docker Swarm on Linux - Portainer Documentation is what I use for mine. Which I think is fine, it's the traefik side that is struggling, given the error in the first post. Which is why I would like to regenerate portainers certificate.
Tried removing acme.json too, in order to regenerate the certificates, but that not only didn't fix the problem all other sites that had the previous certificate setup are now not secure.
Because Portainer is sitting behind Traefik, it can not generate a validated and signed cert. It will always create a custom cert that Traefik will not accept. (yes, there may be exceptions, but why go the hard way?)
switch traefik.http.services.portainer-service.loadbalancer.server.port=9443
for traefik.http.services.frontend.loadbalancer.server.port=9000
got things working, though obviously don't have the secure connection I used to, which is a massive shame.