{"action":"created","issue":{"url":"https://api.github.com/repos/jwilder/nginx-proxy/issues/164","labels_url":"https://api.github.com/repos/jwilder/nginx-proxy/issues/164/labels{/name}","comments_url":"https://api.github.com/repos/jwilder/nginx-proxy/issues/164/comments","events_url":"https://api.github.com/repos/jwilder/nginx-proxy/issues/164/events","html_url":"https://github.com/jwilder/nginx-proxy/issues/164","id":75396617,"number":164,"title":"Get IP Address Upstream ","user":{"login":"mjaverto","id":603286,"avatar_url":"https://avatars.githubusercontent.com/u/603286?v=3","gravatar_id":"","url":"https://api.github.com/users/mjaverto","html_url":"https://github.com/mjaverto","followers_url":"https://api.github.com/users/mjaverto/followers","following_url":"https://api.github.com/users/mjaverto/following{/other_user}","gists_url":"https://api.github.com/users/mjaverto/gists{/gist_id}","starred_url":"https://api.github.com/users/mjaverto/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mjaverto/subscriptions","organizations_url":"https://api.github.com/users/mjaverto/orgs","repos_url":"https://api.github.com/users/mjaverto/repos","events_url":"https://api.github.com/users/mjaverto/events{/privacy}","received_events_url":"https://api.github.com/users/mjaverto/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-05-11T23:44:39Z","updated_at":"2015-05-12T00:27:00Z","closed_at":null,"body":"Great project, I hope you can help me with a small piece and I can contribute back for others in our scenario. \r\n\r\nWe are running self-contained spring boot jars that spin up a Tomcat server on 8080 per container. We need to reverse proxy back to the respective container based on NGINX locations. This project seems to be perfect for what we need but the only issue I run into is getting the container address, {{ $address.IP }}.\r\n\r\nThe error I get is on the upstream line: \r\n\r\n2015/05/11 23:32:09 [emerg] 15#15: unexpected \"{\" in /etc/nginx/conf.d/my-custom.conf:29\r\n\r\nas seen here when DOCKER_CONTAINER is an env correctly set for the container.\r\n\r\n    {{ range $host, $containers := groupByMulti $ \"Env.DOCKER_CONTAINER\" \",\" }}\r\n\r\n        upstream {{ $host }} {\r\n            {{ range $container := $containers }}\r\n                {{ range $address := $container.Addresses }}\r\n                    # {{$container.Name}}\r\n                    server {{ $address.IP }}:8080;\r\n                {{ end }}\r\n            {{ end }}\r\n        }\r\n\r\n    {{ end }}\r\n\r\nI've tried editing many different ways and it seems like {{ $host }} is returning the env variable but I can't seem to get \r\n\r\n            {{ range $container := $containers }}\r\n                {{ range $address := $container.Addresses }}\r\n                    # {{$container.Name}}\r\n                    server {{ $address.IP }}:8080;\r\n                {{ end }}\r\n            {{ end }}\r\n\r\nworking even if I remove the upstream {{ $host }} {} block.\r\n\r\nEssentially I'm trying to get the upstream to look like this:\r\n\r\n    upstream my-service-name {\r\n\r\n        server 172.17.0.7:8080;\r\n\r\n    }\r\n\r\nAnd so it all makes sense, I have our locations hardcoded which works because the proxy pass is the same as Env.DOCKER_CONTAINER\r\n\r\n    location /api/v1/sessions {\r\n\r\n            proxy_pass         http://my-service-name;\r\n            proxy_redirect     off;\r\n            proxy_pass_request_headers      on;\r\n            proxy_set_header   Host $host;\r\n            proxy_set_header   X-Real-IP $remote_addr;\r\n            proxy_set_header   X-Forwarded-For $proxy_add_x_forwarded_for;\r\n            proxy_set_header   X-Forwarded-Host $server_name;\r\n            proxy_set_header   Origin $http_origin;\r\n    }\r\n\r\n\r\nThanks in advance.\r\nDocker version 1.6.0, build bdbc177"},"comment":{"url":"https://api.github.com/repos/jwilder/nginx-proxy/issues/comments/101080676","html_url":"https://github.com/jwilder/nginx-proxy/issues/164#issuecomment-101080676","issue_url":"https://api.github.com/repos/jwilder/nginx-proxy/issues/164","id":101080676,"user":{"login":"mjaverto","id":603286,"avatar_url":"https://avatars.githubusercontent.com/u/603286?v=3","gravatar_id":"","url":"https://api.github.com/users/mjaverto","html_url":"https://github.com/mjaverto","followers_url":"https://api.github.com/users/mjaverto/followers","following_url":"https://api.github.com/users/mjaverto/following{/other_user}","gists_url":"https://api.github.com/users/mjaverto/gists{/gist_id}","starred_url":"https://api.github.com/users/mjaverto/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mjaverto/subscriptions","organizations_url":"https://api.github.com/users/mjaverto/orgs","repos_url":"https://api.github.com/users/mjaverto/repos","events_url":"https://api.github.com/users/mjaverto/events{/privacy}","received_events_url":"https://api.github.com/users/mjaverto/received_events","type":"User","site_admin":false},"created_at":"2015-05-12T00:27:00Z","updated_at":"2015-05-12T00:27:00Z","body":"I actually think I see the problem now is related to:\r\n\r\nhttps://github.com/jwilder/docker-gen/issues/79\r\n\r\nfor\r\n\r\n        {{ range $container := $containers }}\r\n            {{ range $address := $container.Addresses }}\r\n                # {{$container.Name}}\r\n                server {{ $address.IP }}:8080;\r\n            {{ end }}\r\n        {{ end }}\r\n\r\nbut I'm still trying to understand why I have the error with '{'\r\n\r\n    2015/05/11 23:32:09 [emerg] 15#15: unexpected \"{\" in /etc/nginx/conf.d/my-custom.conf:29\r\n\r\nwhen running:\r\n\r\n    docker run --name=nginx-proxy --privileged=true -d -p 80:80 -v /home/mjaverto/dockerapps/nginx/nginx-proxy/nginx-dynamic.tmpl:/etc/nginx/conf.d/my-custom.conf:ro -v /var/run/docker.sock:/tmp/docker.sock jwilder/nginx-proxy "}}