# NOTE: This is an nginx configuration automatically generated by
#       consul-template, there's no point in making manual changes
#       to this file.
#
#       This expects a key to exist under "consular/<app_id>/location"
#       in Consul's KV store. This is used to map a path to a service in
#       Nginx. If the key does not exist the service isn't added to the
#       list of services in the Nginx config.

server {
    listen <%= @listen_addr %>:<%= @listen_port %>;
    server_name <%= @domain %>
    {{range services}}{{$labels := ls (print "consular/" .Name) | explode}}{{if $labels.location}}
    location {{$labels.location | parseJSON}} {
        proxy_pass http://{{.Name}};
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header Host $http_host;{{if $labels.internal}}{{if $labels.internal | parseJSON | parseBool}}
        internal;{{end}}{{end}}
    }
    {{else}}
    # Skipped service {{.Name}} as it does not have a KV location entry.
    {{end}}{{end}}
}

# NOTE: This is an nginx configuration automatically generated by
#       consul-template, there's no point in making manual changes
#       to this file.
#
#       This expects a key to exist under "consular/<app_id>/location"
#       in Consul's KV store. This is used to map a path to a service in
#       Nginx. If the key does not exist the service isn't added to the
#       list of services in the Nginx config.

server {
    listen <%= @listen_addr %>:<%= @listen_port %>;
    server_name <%= @domain %>;
    {{range services}}{{$labels := ls (print "consular/" .Name) | explode}}{{if $labels.location}}
    location {{$labels.location | parseJSON}} {
        proxy_pass http://{{.Name}};
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header Host $http_host;{{if $labels.internal}}{{if $labels.internal | parseJSON | parseBool}}
        internal;{{end}}{{end}}
    }
    {{else}}
    # Skipped service {{.Name}} as it does not have a KV location entry.
    {{end}}{{end}}
}

Fix nginx router template (@jerith)
Fix nginx router template (@jerith)
