{"action":"created","issue":{"url":"https://api.github.com/repos/hashicorp/consul-template/issues/342","labels_url":"https://api.github.com/repos/hashicorp/consul-template/issues/342/labels{/name}","comments_url":"https://api.github.com/repos/hashicorp/consul-template/issues/342/comments","events_url":"https://api.github.com/repos/hashicorp/consul-template/issues/342/events","html_url":"https://github.com/hashicorp/consul-template/issues/342","id":97076544,"number":342,"title":"How to get ServiceAddress from a node when it differs from node address","user":{"login":"digitalronin","id":2338,"avatar_url":"https://avatars.githubusercontent.com/u/2338?v=3","gravatar_id":"","url":"https://api.github.com/users/digitalronin","html_url":"https://github.com/digitalronin","followers_url":"https://api.github.com/users/digitalronin/followers","following_url":"https://api.github.com/users/digitalronin/following{/other_user}","gists_url":"https://api.github.com/users/digitalronin/gists{/gist_id}","starred_url":"https://api.github.com/users/digitalronin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/digitalronin/subscriptions","organizations_url":"https://api.github.com/users/digitalronin/orgs","repos_url":"https://api.github.com/users/digitalronin/repos","events_url":"https://api.github.com/users/digitalronin/events{/privacy}","received_events_url":"https://api.github.com/users/digitalronin/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-07-24T15:23:53Z","updated_at":"2015-07-24T15:38:54Z","closed_at":"2015-07-24T15:38:54Z","body":"I've got a private network where my haproxy servers and backends live, and a consul cluster that sits outside of that. So, my backend nodes advertise a different IP address for the service, compared to the IP address of the node itself, from the consul cluster's POV.\r\n\r\ni.e. something like this;\r\n\r\n    curl http://localhost:8500/v1/catalog/service/myservice?pretty\r\n\r\n    [\r\n        {\r\n            \"Node\": \"backend1\",\r\n            \"Address\": \"1.2.3.4\",\r\n            \"ServiceID\": \"myservice\",\r\n            \"ServiceName\": \"myservice\",\r\n            \"ServiceTags\": null,\r\n            \"ServiceAddress\": \"10.0.0.1\",\r\n            \"ServicePort\": 0\r\n        },\r\n        {\r\n            \"Node\": \"backend2\",\r\n            \"Address\": \"1.2.3.5\",\r\n            \"ServiceID\": \"myservice\",\r\n            \"ServiceName\": \"myservice\",\r\n            \"ServiceTags\": null,\r\n            \"ServiceAddress\": \"10.0.0.2\",\r\n            \"ServicePort\": 0\r\n        },\r\n\r\n        ...\r\n    ]\r\n\r\nI need the ServiceAddress value in my haproxy config, but I can't seem to get it.\r\n\r\nThe relevant part of my template looks like this;\r\n\r\n    {{range service \"myservice\"}}\r\n            server {{.Node}} {{.Address}}:8888{{end}}\r\n\r\n\".Address\" evaluates to the address of the node, not the ServiceAddress, but \".ServiceAddress\" gives me the following error;\r\n\r\n    ServiceAddress is not a field of struct type *dependency.HealthService\r\n\r\nIs there a way to get the ServiceAddress in this situation? i.e. where it's different from the address of the node?\r\n\r\nMy consul-template version is 0.10.0\r\n"},"comment":{"url":"https://api.github.com/repos/hashicorp/consul-template/issues/comments/124561302","html_url":"https://github.com/hashicorp/consul-template/issues/342#issuecomment-124561302","issue_url":"https://api.github.com/repos/hashicorp/consul-template/issues/342","id":124561302,"user":{"login":"digitalronin","id":2338,"avatar_url":"https://avatars.githubusercontent.com/u/2338?v=3","gravatar_id":"","url":"https://api.github.com/users/digitalronin","html_url":"https://github.com/digitalronin","followers_url":"https://api.github.com/users/digitalronin/followers","following_url":"https://api.github.com/users/digitalronin/following{/other_user}","gists_url":"https://api.github.com/users/digitalronin/gists{/gist_id}","starred_url":"https://api.github.com/users/digitalronin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/digitalronin/subscriptions","organizations_url":"https://api.github.com/users/digitalronin/orgs","repos_url":"https://api.github.com/users/digitalronin/repos","events_url":"https://api.github.com/users/digitalronin/events{/privacy}","received_events_url":"https://api.github.com/users/digitalronin/received_events","type":"User","site_admin":false},"created_at":"2015-07-24T15:38:54Z","updated_at":"2015-07-24T15:38:54Z","body":"Sorry, please ignore me. I had an old version of consul on the node where I was trying to generate the template. After updating it, I'm getting the correct address value."}}