I'm facing to a problem, i use Caddy as reverse proxy on my server. I Added a Portainer container with docker. Here is the command to create the portainer container (the one found on the official website)
docker run -d -p 8000:8000 -p 9443:9443 --name portainer --restart=always -v /var/run/docker.sock:/var/run/docker.sock -v portainer_data:/data portainer/portainer-ce:latest
And I use caddy as reverse proxy. Here is the content of the Caddyfile concerning the part that interests us for Portainer.
www.portainer.mydomain.ovh {
root * /usr/share/caddy/test
file_server
reverse_proxy localhost:9443
log {
output file /etc/caddy/portainer.log
}
}
When I access Portainer via the url: https://www.portainer.mydomain.ovh I get this error: Client sent an HTTP request to an HTTPS server But when I access via https://myip:9443 then I access it with a message telling me that the site is not secure and the certificate is invalid.
Do you have any idea what I did wrong please?
EDIT : SOLUTION.
The solution for me was to add port 9000(http) during the docker run. And then caddy makes the reserve on this port. Caddy retrieves a certificate with Let'sEncrypt and the https call works correctly.
docker run -d -p 8000:8000 -p 9000:9000 -p 9443:9443 --name portainer --restart=always -v /var/run/docker.sock:/var/run/docker.sock -v portainer_data:/data portainer/portainer-ce:latest
www.portainer.mydomain.ovh {
reverse_proxy localhost:9000
log {
output file /etc/caddy/portainer.log
}
}