Added the voltha swagger interface to the proxy. Voltha's swagger
interface is now avaialble at http://localhost/swagger.
Made a small change to the way nginx is started because requests to
reload the config were comming in before it had finished loading its
config causing consul-template to choke.
Added a gitignore file in the upstreams directory to ensure that it
gets created in the repo. It needs to be there since the directory is
mounted by the container during the development phase.

Change-Id: I39a1683970ba114f5952913a5beb7cfe9cfe1cc3
diff --git a/nginx_config/includes/swagger.conf b/nginx_config/includes/swagger.conf
new file mode 100644
index 0000000..9e1669c
--- /dev/null
+++ b/nginx_config/includes/swagger.conf
@@ -0,0 +1,24 @@
+location /api/v1/local {
+  proxy_pass http://api-swagger/;
+  rewrite /api/v1/(.*) /api/v1/$1 break;
+  proxy_next_upstream error timeout invalid_header http_500;
+}
+
+location /api/v1/global {
+  proxy_pass http://api-swagger/;
+  rewrite /api/v1/(.*) /api/v1/$1 break;
+  proxy_next_upstream error timeout invalid_header http_500;
+}
+
+location /swagger {
+  proxy_pass http://api-swagger/;
+  rewrite /swagger/(.*) /$1 break;
+  sub_filter "http://localhost/" "http://localhost/swagger/";
+  sub_filter "href='" "href='swagger/";
+  sub_filter 'href="' 'href="swagger/';
+  sub_filter "src='" "src='swagger/";
+  sub_filter 'src="' 'src="swagger/';
+  sub_filter_once off;
+  proxy_next_upstream error timeout invalid_header http_500;
+}
+
diff --git a/nginx_config/nginx-upstreams.ctmpl b/nginx_config/nginx-upstreams.ctmpl
index 747e36b..ec2ce12 100644
--- a/nginx_config/nginx-upstreams.ctmpl
+++ b/nginx_config/nginx-upstreams.ctmpl
@@ -3,6 +3,11 @@
     server {{.Address}}:{{.Port}};
     {{end}}
 }
+upstream api-swagger {
+    {{range service "chameleon-rest" "any"}}
+    server {{.Address}}:{{.Port}};
+    {{end}}
+}
 upstream api-docker {
     {{range service "portainer" "any"}}
     server {{.Address}}:{{.Port}};
diff --git a/nginx_config/start_service.sh b/nginx_config/start_service.sh
index eaaae61..bb0ed37 100755
--- a/nginx_config/start_service.sh
+++ b/nginx_config/start_service.sh
@@ -1,5 +1,6 @@
 #!/bin/bash
 
 cd /
-#nginx -c /nginx_config/nginx.conf&
-exec consul-template -reload-signal='SIGHUP' -consul $CONSUL_ADDR -template="nginx_config/nginx-upstreams.ctmpl:nginx_config/upstreams/voltha-upstreams.conf:nginx -s reload"  -exec='/usr/sbin/nginx -c /nginx_config/nginx.conf -g "daemon off;"'
+nginx -c /nginx_config/nginx.conf&
+sleep 2 # Let nginx get settled bfore starting consul-template to avoid attemtps to reload resulting in errors.
+exec consul-template -reload-signal='SIGHUP' -consul $CONSUL_ADDR -template="nginx_config/nginx-upstreams.ctmpl:nginx_config/upstreams/voltha-upstreams.conf:nginx -s reload"
diff --git a/nginx_config/upstreams/.gitignore b/nginx_config/upstreams/.gitignore
new file mode 100644
index 0000000..68ba743
--- /dev/null
+++ b/nginx_config/upstreams/.gitignore
@@ -0,0 +1 @@
+voltha-upstreams.conf