how to configure consul-template in nginx load balance

98 views
Skip to first unread message

Rajasekaran R

unread,
Dec 5, 2016, 1:49:13 AM12/5/16
to Consul
Hi Team,

I followed this blog https://jlordiales.me/2015/04/01/consul-template/ to test consul, registrator, consul-template with nginx but I am struggling with nginx configuration. I am not able to perform the steps from "Combining Consul Template and a reverse proxy" kindly suggest is there any alternate way to resolve this issue.

1. raja@treselle-VirtualBox:~/consul$ docker run -p 8080:80 -d --name nginx --volume /tmp/service.ctmpl:/templates/service.ctmpl --link consul:consul jlordiales/nginx-consul
2. curl $DOCKER_IP:8080/python-micro-service/ 
<html>
<head><title>404 Not Found</title></head>
<body bgcolor="white">
<center><h1>404 Not Found</h1></center>
<hr><center>nginx/1.7.11</center>
</body>
</html>

3. my /tmp/service.ctmpl file.

upstream python-service {
  least_conn;
  {{range service "python-micro-service"}}server {{.Address}}:{{.Port}} max_fails=3 fail_timeout=60 weight=1;
  {{else}}server 127.0.0.1:65535; # force a 502{{end}}
}

server {
  listen 80 default_server;

  charset utf-8;

  location ~ ^/python-micro-service/(.\*)$ {
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header Host $host;
    proxy_set_header X-Real-IP $remote_addr;
  }
}

Kindly suggest me how to fix this issue. Or is there any other container available to develop consul-template for nginx LB.

Regards,
Raja

Reply all
Reply to author
Forward
0 new messages