Consul-template nginx vhost

Hello. I would need some feedback on how to accomplish Nginx templating using consul-template. Some context:
I’m registering a service called domain_com that is running on 3 nodes. First I’m creating backed where I do:
{{ range services }}
{{- if in .Tags “requiresProxy” -}}
upstream upstream-{{ .Name }} {

{{ range service .Name }}

server {{ .Address }}:{{ .Port }};
{{ end }}
{{ end }}
{{ end }}
And that part is clear. Now I need to automatically create virtual hosts for those services by mapping ServiceMeta “domainName” key to nginx server_name directive.

The problem is that I get 3 identical virtual hosts created, because I need to loop through {{ range services }} to be able to access {{ index .ServiceMeta “domainName” }}.

I understand that {{ range services }} gets me all endpoints in my service ( on all 3 nodes) but how do I generate only single vHost instead of 3?

Is there some sort of grouping or getting out only the first occurrence of service in a loop?
Note: All my {{ range services }} have exactly the same ServiceMeta and I’m aware that by grouping there might be different Meta tags on different service nodes, but that will not happen in my use-case.
Thanks a lot for the help!