1

I am trying to add a new node into my swarm over the internet but it doesn't seem to connect through a proxy.

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 can't 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.

1 Answer 1

2

The swarm protocol is not http, so you will not be able to pass it through a proxy. Swarm nodes need direct communication between each node on port 2377/tcp (or your configured swarm port), 7946/both, and 4789/udp. If you configure an overlay network with the secure option for IPSec, then you'll also need protocol 50 open between the nodes.

4
  • i have updated my caddy config to not specify port number. i then opened up port 7946 and 4789. port 50 is not required as i am not using an overlay network. i then ran the command: sudo docker swarm join --token <some-long-hash> swarm.mydomain.com:2377. the domain name will forward all traffic to the node where the ports mentioned are open on both nodes. i get the same error: Error response from daemon: rpc error: code = Unavailable desc = grpc: the connection is unavailable. im sure my setup is not normal, but im quite new to devops so i dont know if this is this even possible?
    – X0r0N
    Commented May 24, 2018 at 18:11
  • Stop using the proxy, do not run your join to the hostname pointing to caddy. Do the join directly to the manager ip, which gets output by docker when you request the join token. Changing the command docker gives you is causing your errors.
    – BMitch
    Commented May 24, 2018 at 18:15
  • the manager is in a private network and the node i am trying to connect is connecting over the internet. this is why i am trying to proxy the connection. if it was possible to initialise a swarm token with specifying a domain, then this would work. it seems docker swarm will not allow swarm join token by domain name. this is not a common or secure use-case, but this feature may be at least be useful for some people like me who are trying to learn devops.
    – X0r0N
    Commented May 24, 2018 at 19:20
  • If you need to connect to a non-internet accessable system, then a vpn may be the best option. A proxy will not work.
    – BMitch
    Commented May 24, 2018 at 20:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.