nginx.tmpl

Config balancer NGINX
 avatar
Geksogen
plain_text
2 years ago
497 B
1
Indexable
Never
{{ range $host, $containers := groupBy $ "Env.VIRTUAL_HOST" }}
upstream {{ $host }} {

{{ range $index, $value := $containers }}
    {{ with $address := index $value.Addresses 0 }}
    server {{ $value.Hostname }}:{{ $address.Port }};
    {{ end }}
{{ end }}

}

server {

  listen 80;

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

  location /api {
      proxy_pass http://{{ $host }};
  }
}
{{ end }}