From 4a7d4d355540711999674599a880da48427f01d1 Mon Sep 17 00:00:00 2001 From: Paul Bellamy Date: Tue, 9 Jun 2015 14:41:17 +0100 Subject: [PATCH 1/4] [proxy] documenting -L option --- site/proxy.md | 12 ++++++++---- weave | 3 ++- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/site/proxy.md b/site/proxy.md index 1dc35801..58030ad1 100644 --- a/site/proxy.md +++ b/site/proxy.md @@ -35,9 +35,13 @@ argument, e.g. host1$ weave launch-proxy -H tcp://127.0.0.1:4243 -The proxy listens on port 12375, on all network interfaces. All docker -commands can be run via the proxy, so it is safe to globally adjust -your `DOCKER_HOST` to point at the proxy, e.g. +By default, the proxy listens on port 12375, on all network +interfaces. This can be adjusted with the `-L` argument, e.g. + + host1$ weave launch-proxy -L 127.0.0.1:9999 + +All docker commands can be run via the proxy, so it is safe to +globally adjust your `DOCKER_HOST` to point at the proxy, e.g. host1$ export DOCKER_HOST=tcp://localhost:12375 host1$ docker ps @@ -46,7 +50,7 @@ your `DOCKER_HOST` to point at the proxy, e.g. If you are working with a remote docker daemon, then `localhost` in the above needs to be replaced with the docker daemon host, and any firewalls inbetween need to be configured to permit access to -port 12375. +the proxy port. ## Usage diff --git a/weave b/weave index 26f631cb..fff7c35b 100755 --- a/weave +++ b/weave @@ -28,7 +28,7 @@ usage() { echo "weave launch [-password ] [-nickname ] [-nodiscovery]" echo " [-iprange ] ..." echo "weave launch-dns " - echo "weave launch-proxy [-H ] [--with-dns] [--with-ipam]" + echo "weave launch-proxy [-H ] [-L
] [--with-dns] [--with-ipam]" echo "weave connect [--replace] [ ...]" echo "weave forget ..." echo "weave run [--with-dns] [ ...] ..." @@ -51,6 +51,7 @@ usage() { echo "where = [:]" echo " = /" echo " = or weave internal peer ID" + echo "
= []:" exit 1 } From 0da9669e5c5a2cc5203a4bd54d3bde092ba426c4 Mon Sep 17 00:00:00 2001 From: Paul Bellamy Date: Tue, 9 Jun 2015 14:41:51 +0100 Subject: [PATCH 2/4] [proxy] removing unneeded port expose --- weave | 2 -- 1 file changed, 2 deletions(-) diff --git a/weave b/weave index fff7c35b..94ee89f7 100755 --- a/weave +++ b/weave @@ -171,7 +171,6 @@ MTU=65535 PORT=${WEAVE_PORT:-6783} HTTP_PORT=6784 DNS_HTTP_PORT=6785 -PROXY_PORT=12375 PROXY_CONTAINER_NAME=weaveproxy @@ -945,7 +944,6 @@ case "$COMMAND" in # when launching the weaveproxy container. proxy_args "$@" PROXY_CONTAINER=$(docker run --privileged -d --name=$PROXY_CONTAINER_NAME --net=host \ - -p $PROXY_PORT:$PROXY_PORT/tcp \ $PROXY_VOLUMES \ -v /var/run/docker.sock:/var/run/docker.sock \ -v /proc:/hostproc \ From 447a00ba7e19cf1da59a1954f34cbae721b70c10 Mon Sep 17 00:00:00 2001 From: Paul Bellamy Date: Tue, 9 Jun 2015 15:25:24 +0100 Subject: [PATCH 3/4] [proxy] Add support for tcp:// prefix on listen addresses --- prog/weaveproxy/main.go | 12 +++++++++++- weave | 2 +- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/prog/weaveproxy/main.go b/prog/weaveproxy/main.go index 836beeb7..1a5e30f4 100644 --- a/prog/weaveproxy/main.go +++ b/prog/weaveproxy/main.go @@ -13,7 +13,7 @@ import ( var ( version = "(unreleased version)" defaultDockerAddr = "unix:///var/run/docker.sock" - defaultListenAddr = ":12375" + defaultListenAddr = "tcp://0.0.0.0:12375" ) func main() { @@ -52,6 +52,16 @@ func main() { Info.Println("weave proxy", version) Info.Println("Command line arguments:", strings.Join(os.Args[1:], " ")) + protoAddrParts := strings.SplitN(c.ListenAddr, "://", 2) + if len(protoAddrParts) == 2 { + if protoAddrParts[0] != "tcp" { + Error.Fatalf("Invalid protocol format: %q", protoAddrParts[0]) + } + c.ListenAddr = protoAddrParts[1] + } else { + c.ListenAddr = protoAddrParts[0] + } + p, err := proxy.NewProxy(c) if err != nil { Error.Fatalf("Could not start proxy: %s", err) diff --git a/weave b/weave index 94ee89f7..96ef80fa 100755 --- a/weave +++ b/weave @@ -51,7 +51,7 @@ usage() { echo "where = [:]" echo " = /" echo " = or weave internal peer ID" - echo "
= []:" + echo "
= [tcp://][]:" exit 1 } From 6bb087cecd580ac6fcefbab18625b20bbf5d4c8e Mon Sep 17 00:00:00 2001 From: Paul Bellamy Date: Wed, 10 Jun 2015 09:56:17 +0100 Subject: [PATCH 4/4] [proxy] Renaming flags: `-H` -> `-D`, `-L` -> `-H` As per discussion in issue 875 --- prog/weaveproxy/main.go | 4 ++-- site/proxy.md | 8 ++++---- weave | 2 +- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/prog/weaveproxy/main.go b/prog/weaveproxy/main.go index 1a5e30f4..4b8f039b 100644 --- a/prog/weaveproxy/main.go +++ b/prog/weaveproxy/main.go @@ -29,8 +29,8 @@ func main() { c.Version = version getopt.BoolVarLong(&debug, "debug", 'd', "log debugging information") getopt.BoolVarLong(&justVersion, "version", 0, "print version and exit") - getopt.StringVar(&c.ListenAddr, 'L', fmt.Sprintf("address on which to listen (default %s)", defaultListenAddr)) - getopt.StringVar(&c.DockerAddr, 'H', fmt.Sprintf("docker daemon URL to proxy (default %s)", defaultDockerAddr)) + getopt.StringVar(&c.ListenAddr, 'H', fmt.Sprintf("address on which to listen (default %s)", defaultListenAddr)) + getopt.StringVar(&c.DockerAddr, 'D', fmt.Sprintf("docker daemon URL to proxy (default %s)", defaultDockerAddr)) getopt.StringVarLong(&c.TLSConfig.CACert, "tlscacert", 0, "Trust certs signed only by this CA") getopt.StringVarLong(&c.TLSConfig.Cert, "tlscert", 0, "Path to TLS certificate file") getopt.BoolVarLong(&c.TLSConfig.Enabled, "tls", 0, "Use TLS; implied by --tlsverify") diff --git a/site/proxy.md b/site/proxy.md index 58030ad1..bfbe7eef 100644 --- a/site/proxy.md +++ b/site/proxy.md @@ -30,15 +30,15 @@ To start the proxy, run host1$ weave launch-proxy By default, the proxy will connect to docker at -`unix:///var/run/docker.sock`. This can be adjusted with the `-H` +`unix:///var/run/docker.sock`. This can be adjusted with the `-D` argument, e.g. - host1$ weave launch-proxy -H tcp://127.0.0.1:4243 + host1$ weave launch-proxy -D tcp://127.0.0.1:4243 By default, the proxy listens on port 12375, on all network -interfaces. This can be adjusted with the `-L` argument, e.g. +interfaces. This can be adjusted with the `-H` argument, e.g. - host1$ weave launch-proxy -L 127.0.0.1:9999 + host1$ weave launch-proxy -H tcp://127.0.0.1:9999 All docker commands can be run via the proxy, so it is safe to globally adjust your `DOCKER_HOST` to point at the proxy, e.g. diff --git a/weave b/weave index 96ef80fa..68603848 100755 --- a/weave +++ b/weave @@ -28,7 +28,7 @@ usage() { echo "weave launch [-password ] [-nickname ] [-nodiscovery]" echo " [-iprange ] ..." echo "weave launch-dns " - echo "weave launch-proxy [-H ] [-L
] [--with-dns] [--with-ipam]" + echo "weave launch-proxy [-D ] [-H
] [--with-dns] [--with-ipam]" echo "weave connect [--replace] [ ...]" echo "weave forget ..." echo "weave run [--with-dns] [ ...] ..."