consul-template and registrator

https://www.cnblogs.com/zhangdk/p/Registrator_reference.html#registrator%E9%80%89%E9%A1%B9

https://www.hi-linux.com/posts/36431.html    consul-template

https://book-consul-guide.vnzmi.com/11_consul_template.html

{{range services}} {{$name := .Name}} {{$service := service .Name}}
upstream {{$name}} {
  zone upstream-{{$name}} 64k;
  {{range $service}}server {{.Address}}:{{.Port}} max_fails=3 fail_timeout=60 weight=1;
  {{else}}server 127.0.0.1:65535; # force a 502{{end}}
} {{end}}

server {
  listen 80 default_server;

  location / {
    root /usr/share/nginx/html/;
    index index.html;
  }

  location /stub_status {
    stub_status;
  }

{{range services}} {{$name := .Name}}
  location /{{$name}} {
    proxy_pass http://{{$name}};
  }
{{end}}
}