Docker Swarm join-token not working

i am trying to add a new node into my swarm over the internet but it doesn’t seem to connect through a poxy.

i am trying to proxy using caddy. the proxy configuration results in the same as for any other server like proxy_pass in nginx.

caddy automatically sets up HTTPS for the subdomain and all traffic is set to be redirected from port 80 to 443. my caddy configuration is:

swarm.mydomain.com {
    proxy / http://<docker-swarm-manager-ip>:2377 {
        transparent
    }
}

from the docker swarm manager, i get the join-token which gives me something like:

docker swarm join --token <some-long-hash> <docker-swarm-manager-ip>:2377

on the node i want to connect to the swarm, i have tried the command:

sudo docker swarm join --token <some-long-hash> swarm.mydomain.com

this gives me the error:

Error response from daemon: rpc error: code = Unavailable desc = grpc: the connection is unavailable

i then tried specifying the SSL port:

sudo docker swarm join --token <some-long-hash> swarm.mydomain.com:443

this gives me the error:

Error response from daemon: rpc error: code = FailedPrecondition desc = transport: received the unexpected content-type "text/plain; charset=utf-8"

i am new to docker swarm and i cant find any similar setup online. any help is appreciated.

note:

  • i am able to ping the manager from the node successfully.
  • port 2377 is is open on the manager and the node i want to connect.