Skip to content

Commit 8e8513e

Browse files
author
Lee Valentine
committed
TRAFFIC-448: allow the user to specify the proxy address and port to bind to, falling back to 127.0.0.1 and random port if not specified
1 parent 607dcff commit 8e8513e

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

cmd/cloudflared/tunnel/cmd.go

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import (
1212
"reflect"
1313
"runtime"
1414
"runtime/trace"
15+
"strconv"
1516
"strings"
1617
"sync"
1718
"time"
@@ -506,7 +507,7 @@ func StartServer(
506507
}
507508

508509
if staticHost := hostnameFromURI(c.String("url")); isProxyDestinationConfigured(staticHost, c) {
509-
listener, err := net.Listen("tcp", "127.0.0.1:")
510+
listener, err := net.Listen("tcp", net.JoinHostPort(c.String("proxy-address"), strconv.Itoa(c.Int("proxy-port"))))
510511
if err != nil {
511512
log.Errorf("Cannot start Websocket Proxy Server: %s", err)
512513
return errors.Wrap(err, "Cannot start Websocket Proxy Server")
@@ -947,6 +948,20 @@ func tunnelFlags(shouldHide bool) []cli.Flag {
947948
Value: 4,
948949
Hidden: true,
949950
}),
951+
altsrc.NewStringFlag(&cli.StringFlag{
952+
Name: "proxy-address",
953+
Usage: "Listen address for the proxy.",
954+
Value: "127.0.0.1",
955+
EnvVars: []string{"TUNNEL_PROXY_ADDRESS"},
956+
Hidden: shouldHide,
957+
}),
958+
altsrc.NewIntFlag(&cli.IntFlag{
959+
Name: "proxy-port",
960+
Usage: "Listen port for the proxy.",
961+
Value: 0,
962+
EnvVars: []string{"TUNNEL_PROXY_PORT"},
963+
Hidden: shouldHide,
964+
}),
950965
altsrc.NewDurationFlag(&cli.DurationFlag{
951966
Name: "proxy-connect-timeout",
952967
Usage: "HTTP proxy timeout for establishing a new connection",

0 commit comments

Comments
 (0)