From 7a3da7db26d4f5f35041b83e6eccf42d961d8fd4 Mon Sep 17 00:00:00 2001 From: Andy Lo-A-Foe Date: Tue, 11 Aug 2015 14:14:21 +0200 Subject: [PATCH 1/6] Add -http-port option to change the HTTP API port This is useful when pushing consul to PaaS like Cloud Foundry making the HTTP API easily routable. --- command/agent/command.go | 1 + command/agent/config.go | 8 ++++++++ 2 files changed, 9 insertions(+) diff --git a/command/agent/command.go b/command/agent/command.go index 008eed42d..e3ce2787e 100644 --- a/command/agent/command.go +++ b/command/agent/command.go @@ -80,6 +80,7 @@ func (c *Command) readConfig() *Config { cmdFlags.StringVar(&cmdConfig.ClientAddr, "client", "", "address to bind client listeners to (DNS, HTTP, HTTPS, RPC)") cmdFlags.StringVar(&cmdConfig.BindAddr, "bind", "", "address to bind server listeners to") + cmdFlags.IntVar(&cmdConfig.HttpPort, "http-port", 0, "http port to use") cmdFlags.StringVar(&cmdConfig.AdvertiseAddr, "advertise", "", "address to advertise instead of bind addr") cmdFlags.StringVar(&cmdConfig.AdvertiseAddrWan, "advertise-wan", "", "address to advertise on wan instead of bind or advertise addr") diff --git a/command/agent/config.go b/command/agent/config.go index 5b3357a34..22331d0d6 100644 --- a/command/agent/config.go +++ b/command/agent/config.go @@ -141,6 +141,11 @@ type Config struct { // client services (DNS, HTTP, HTTPS, RPC) ClientAddr string `mapstructure:"client_addr"` + // HttpPort the HTTP port to listen on. + // This is useful e.g. when deploying to Cloud Foundry to make + // the HTTP API easily routable + HttpPort int `mapstructure:"http_port"` + // BindAddr is used to control the address we bind to. // If not specified, the first private IP we find is used. // This controls the address we use for cluster facing @@ -849,6 +854,9 @@ func MergeConfig(a, b *Config) *Config { if b.BindAddr != "" { result.BindAddr = b.BindAddr } + if b.HttpPort != 0 { + result.Ports.HTTP = b.HttpPort + } if b.AdvertiseAddr != "" { result.AdvertiseAddr = b.AdvertiseAddr } From 7e2ecf6a3c7c4c2936c21cf43bf818b6096c784a Mon Sep 17 00:00:00 2001 From: Andy Lo-A-Foe Date: Thu, 20 Aug 2015 20:19:35 +0200 Subject: [PATCH 2/6] Add documentation for http-port option --- command/agent/command.go | 1 + 1 file changed, 1 insertion(+) diff --git a/command/agent/command.go b/command/agent/command.go index e3ce2787e..de474567d 100644 --- a/command/agent/command.go +++ b/command/agent/command.go @@ -927,6 +927,7 @@ Options: -atlas-token=token Provides the Atlas API token -bootstrap Sets server to bootstrap mode -bind=0.0.0.0 Sets the bind address for cluster communication + -http-port=8500 Sets the HTTP API port to listen on -bootstrap-expect=0 Sets server to expect bootstrap mode. -client=127.0.0.1 Sets the address to bind for client access. This includes RPC, DNS, HTTP and HTTPS (if configured) From 3d133ab78c7f7ee17ab65118b61fbe935b023f30 Mon Sep 17 00:00:00 2001 From: Andy Lo-A-Foe Date: Thu, 20 Aug 2015 20:27:20 +0200 Subject: [PATCH 3/6] Use Ports.HTTP directly --- command/agent/command.go | 2 +- command/agent/config.go | 9 ++------- 2 files changed, 3 insertions(+), 8 deletions(-) diff --git a/command/agent/command.go b/command/agent/command.go index de474567d..2ea01171f 100644 --- a/command/agent/command.go +++ b/command/agent/command.go @@ -80,7 +80,7 @@ func (c *Command) readConfig() *Config { cmdFlags.StringVar(&cmdConfig.ClientAddr, "client", "", "address to bind client listeners to (DNS, HTTP, HTTPS, RPC)") cmdFlags.StringVar(&cmdConfig.BindAddr, "bind", "", "address to bind server listeners to") - cmdFlags.IntVar(&cmdConfig.HttpPort, "http-port", 0, "http port to use") + cmdFlags.IntVar(&cmdConfig.Ports.HTTP, "http-port", 0, "http port to use") cmdFlags.StringVar(&cmdConfig.AdvertiseAddr, "advertise", "", "address to advertise instead of bind addr") cmdFlags.StringVar(&cmdConfig.AdvertiseAddrWan, "advertise-wan", "", "address to advertise on wan instead of bind or advertise addr") diff --git a/command/agent/config.go b/command/agent/config.go index 22331d0d6..716b6e8e1 100644 --- a/command/agent/config.go +++ b/command/agent/config.go @@ -141,11 +141,6 @@ type Config struct { // client services (DNS, HTTP, HTTPS, RPC) ClientAddr string `mapstructure:"client_addr"` - // HttpPort the HTTP port to listen on. - // This is useful e.g. when deploying to Cloud Foundry to make - // the HTTP API easily routable - HttpPort int `mapstructure:"http_port"` - // BindAddr is used to control the address we bind to. // If not specified, the first private IP we find is used. // This controls the address we use for cluster facing @@ -854,8 +849,8 @@ func MergeConfig(a, b *Config) *Config { if b.BindAddr != "" { result.BindAddr = b.BindAddr } - if b.HttpPort != 0 { - result.Ports.HTTP = b.HttpPort + if b.Ports.HTTP != 0 { + result.Ports.HTTP = b.Ports.HTTP } if b.AdvertiseAddr != "" { result.AdvertiseAddr = b.AdvertiseAddr From 325b54649a5ebb63dffbc4f2af3c5abe0201051b Mon Sep 17 00:00:00 2001 From: Andy Lo-A-Foe Date: Thu, 20 Aug 2015 20:46:20 +0200 Subject: [PATCH 4/6] Remove duplicate code --- command/agent/config.go | 3 --- 1 file changed, 3 deletions(-) diff --git a/command/agent/config.go b/command/agent/config.go index 716b6e8e1..5b3357a34 100644 --- a/command/agent/config.go +++ b/command/agent/config.go @@ -849,9 +849,6 @@ func MergeConfig(a, b *Config) *Config { if b.BindAddr != "" { result.BindAddr = b.BindAddr } - if b.Ports.HTTP != 0 { - result.Ports.HTTP = b.Ports.HTTP - } if b.AdvertiseAddr != "" { result.AdvertiseAddr = b.AdvertiseAddr } From e9ee1f9bea02011d6c3780c8cec9031ed3f79a41 Mon Sep 17 00:00:00 2001 From: Andy Lo-A-Foe Date: Wed, 2 Sep 2015 05:36:09 +0200 Subject: [PATCH 5/6] Update agent options section on the website --- website/source/docs/agent/options.html.markdown | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/website/source/docs/agent/options.html.markdown b/website/source/docs/agent/options.html.markdown index d84c2cc90..c7790a2c0 100644 --- a/website/source/docs/agent/options.html.markdown +++ b/website/source/docs/agent/options.html.markdown @@ -84,6 +84,11 @@ The options below are all specified on the command-line. IP address. Consul uses both TCP and UDP and the same port for both. If you have any firewalls, be sure to allow both protocols. +* `-http-port` - the HTTP API port to listen on. + This overrides the default port 8500. This option is very useful when deploying Consul + to an environment which communicates the HTTP port through the environment e.g. PaaS like CloudFoundry, allowing + you to set the port directly via a Procfile. + * `-client` - The address to which Consul will bind client interfaces, including the HTTP, DNS, and RPC servers. By default, this is "127.0.0.1", From 46e614ae70158616626e73e069e6e93d0a6c0099 Mon Sep 17 00:00:00 2001 From: Andy Lo-A-Foe Date: Wed, 2 Sep 2015 06:28:55 +0200 Subject: [PATCH 6/6] Position it alphabetically --- website/source/docs/agent/options.html.markdown | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/website/source/docs/agent/options.html.markdown b/website/source/docs/agent/options.html.markdown index c7790a2c0..c3fe18895 100644 --- a/website/source/docs/agent/options.html.markdown +++ b/website/source/docs/agent/options.html.markdown @@ -84,11 +84,6 @@ The options below are all specified on the command-line. IP address. Consul uses both TCP and UDP and the same port for both. If you have any firewalls, be sure to allow both protocols. -* `-http-port` - the HTTP API port to listen on. - This overrides the default port 8500. This option is very useful when deploying Consul - to an environment which communicates the HTTP port through the environment e.g. PaaS like CloudFoundry, allowing - you to set the port directly via a Procfile. - * `-client` - The address to which Consul will bind client interfaces, including the HTTP, DNS, and RPC servers. By default, this is "127.0.0.1", @@ -144,6 +139,11 @@ The options below are all specified on the command-line. initialized with an encryption key, then the provided key is ignored and a warning will be displayed. +* `-http-port` - the HTTP API port to listen on. + This overrides the default port 8500. This option is very useful when deploying Consul + to an environment which communicates the HTTP port through the environment e.g. PaaS like CloudFoundry, allowing + you to set the port directly via a Procfile. + * `-join` - Address of another agent to join upon starting up. This can be specified multiple times to specify multiple agents to join. If Consul is