If I use my domain name, such as: portainer.domain.tld, I got a 526 SSL invalid certificate error or connection timed out, depending of what useless things I'm configuring.
So I tried with local domain name, but I got a ERR_CONNECTION_REFUSED error.
I tried several configurations, none of them worked. Here's my last attempt.
My router port forward from 80 to 49870 internal to try to reach Traefik.
I can make: curl -H Host:whoami.domain.tld http://192.168.1.200:49870 (192.168.1.200 is the server where Traefik is)
The final version of my Traefik configuration will need to be able to cope with different Docker networks. For security first, and because I don't want to edit all my services to put them in a single network. No way.
For now, I just try to make Traefik work outside of my network (from a web browser typically).
I don't know what's wrong from this side. I use the same method as for Nginx, when my IP gets a request on port 443, It redirects it to my server, and then, the container takes care of the rest.
You can have a different Docker network for every service, but Traefik needs to be part of it. Then use labels on your service to set according traefik.docker.network.
Make sure your domain whoami.domain.tld is set in DNS to resolve to the IP, either in Internet with a paid provider, in your Internet router or in your local hosts file.
It’s very confusing that you name your Traefik service „portainer“.
Even on trying on another machine, It does not work. I don't understand. Requests come because if I switch to 443, I have SSL invalid certificate error but on 80, It just loads. I tried with curl and I got a 301 error.
I think I'm ready to pay 5$ on PayPal to solve this shit, It's enough.
Looking again at your original post: not sure how portainer should work via Traefik, because they don’t share the same Docker network. Did you access it directly via the exposed port?
Traefik TLS files need to be configured in a “dynamic configuration”, so you need something like traefik-dynamic.yml which you load in traefik.yml with a provider.file (next to provider.docker). TLS docs, file docs.
And if you try accessing your app with curl and http and https, you should expose the default ports 80 and 443 or add the ports to you curl request.