From f1c96df3f32538cd8dda3cccb16adbe5f49b7e8d Mon Sep 17 00:00:00 2001 From: Diptanu Choudhury Date: Tue, 24 May 2016 17:27:09 -0700 Subject: [PATCH] Using the bind addr as server's IP if advertise addr and addresses.HTTP is not specified --- command/agent/agent.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/command/agent/agent.go b/command/agent/agent.go index 6f12d3896..47be6e190 100644 --- a/command/agent/agent.go +++ b/command/agent/agent.go @@ -159,9 +159,13 @@ func (a *Agent) serverConfig() (*nomad.Config, error) { if port := a.config.Ports.Serf; port != 0 { conf.SerfConfig.MemberlistConfig.BindPort = port } - a.serverHTTPAddr = fmt.Sprintf("%v:%v", a.config.Addresses.HTTP, a.config.Ports.HTTP) + if a.config.AdvertiseAddrs.HTTP != "" { a.serverHTTPAddr = a.config.AdvertiseAddrs.HTTP + } else if a.config.Addresses.HTTP != "" { + a.serverHTTPAddr = fmt.Sprintf("%v:%v", a.config.Addresses.HTTP, a.config.Ports.HTTP) + } else if a.config.BindAddr != "" { + a.serverHTTPAddr = fmt.Sprintf("%v:%v", a.config.BindAddr, a.config.Ports.HTTP) } if gcThreshold := a.config.Server.NodeGCThreshold; gcThreshold != "" {