diff --git a/consul/client.go b/consul/client.go index e7155a144..8d5915117 100644 --- a/consul/client.go +++ b/consul/client.go @@ -181,6 +181,9 @@ func (c *Client) setupSerf(conf *serf.Config, ch chan serf.Event, path string) ( conf.RejoinAfterLeave = c.config.RejoinAfterLeave conf.Merge = &lanMergeDelegate{dc: c.config.Datacenter} conf.DisableCoordinates = c.config.DisableCoordinates + if wanAddr := c.config.SerfWANConfig.MemberlistConfig.AdvertiseAddr; wanAddr != "" { + conf.Tags["WanAddr"] = wanAddr + } if err := ensurePath(conf.SnapshotPath, false); err != nil { return nil, err } diff --git a/consul/fsm.go b/consul/fsm.go index 1d1049e96..5ccf7afcd 100644 --- a/consul/fsm.go +++ b/consul/fsm.go @@ -472,8 +472,9 @@ func (s *consulSnapshot) persistNodes(sink raft.SnapshotSink, for node := nodes.Next(); node != nil; node = nodes.Next() { n := node.(*structs.Node) req := structs.RegisterRequest{ - Node: n.Node, - Address: n.Address, + Node: n.Node, + Address: n.Address, + WanAddress: n.WanAddress, } // Register the node itself diff --git a/consul/leader.go b/consul/leader.go index 55c487b4f..ff926c98b 100644 --- a/consul/leader.go +++ b/consul/leader.go @@ -418,6 +418,7 @@ AFTER_CHECK: Datacenter: s.config.Datacenter, Node: member.Name, Address: member.Addr.String(), + WanAddress: member.Tags["WanAddr"], Service: service, Check: &structs.HealthCheck{ Node: member.Name, @@ -460,6 +461,7 @@ func (s *Server) handleFailedMember(member serf.Member) error { Datacenter: s.config.Datacenter, Node: member.Name, Address: member.Addr.String(), + WanAddress: member.Tags["WanAddr"], Check: &structs.HealthCheck{ Node: member.Name, CheckID: SerfCheckID, diff --git a/consul/server.go b/consul/server.go index 7a59cb594..5f15975c7 100644 --- a/consul/server.go +++ b/consul/server.go @@ -299,6 +299,9 @@ func (s *Server) setupSerf(conf *serf.Config, ch chan serf.Event, path string, w if s.config.BootstrapExpect != 0 { conf.Tags["expect"] = fmt.Sprintf("%d", s.config.BootstrapExpect) } + if wanAddr := s.config.SerfWANConfig.MemberlistConfig.AdvertiseAddr; wanAddr != "" { + conf.Tags["WanAddr"] = wanAddr + } conf.MemberlistConfig.LogOutput = s.config.LogOutput conf.LogOutput = s.config.LogOutput conf.EventCh = ch