Answers: <p>I have done this in the past using <a href="https://github.com/hashicorp/consul-template" rel="nofollow noreferrer">https://github.com/hashicorp/consul-template</a>.</p>
  
  <p>What <code>consul-template</code> does it generate a configuration file (for nginx) based on a certain template you provide. And the values that it fills into this template are coming from the configuration stored in <code>consul</code>.</p>
  
  <p>Each time your micro-services register themselves in <code>consul</code> and need to be addressed in the nginx configuration file, <code>consul-template</code> does it for you by changing the file and sending a <code>SIGHUP</code> (<code>kill -1</code>) to the nginx process that makes it reload nginx configuration.</p>
  
  <p>The repository for <code>consule-template</code> contains an example of managing <code>nginx</code> <a href="https://github.com/hashicorp/consul-template/blob/master/examples/nginx.md" rel="nofollow noreferrer">https://github.com/hashicorp/consul-template/blob/master/examples/nginx.md</a></p>
  
  <hr>
  
  <p>If you are using <em>Nginx Plus</em>, which is the commercial version of Nginx. Then it has support for Consul built-in. <a href="https://www.nginx.com/blog/service-discovery-with-nginx-plus-and-consul/" rel="nofollow noreferrer">https://www.nginx.com/blog/service-discovery-with-nginx-plus-and-consul/</a> and <a href="https://www.nginx.com/blog/service-discovery-nginx-plus-srv-records-consul-dns/" rel="nofollow noreferrer">https://www.nginx.com/blog/service-discovery-nginx-plus-srv-records-consul-dns/</a> go into depth on this subject.</p>
  
Answers: CC BY-SA 3.0
Answers: 2018-04-09T10:29:08.873Z
Answers: I went through these tutorials but didn't get much help because all the things are new for me, means I am beginner in both consul and nginx, can you please provide me a simple basic example with both nginx and consul, I will be heartily thankful to you, because of this I am stuck from last 2 days
Answers: Ravat Tailor
Answers: CC BY-SA 3.0
Answers: 2018-04-09T11:23:23.783Z
Answers: Updated the answer to include a link to an example.
Answers: Evgeny Zislis
Answers: CC BY-SA 3.0
Answers: 2018-04-09T10:08:18.027Z
Answers: 2018-04-09T11:23:06.640Z
Answers: 2018-04-09T11:23:06.640Z
Answers: Evgeny Zislis
Body: <p>I am from development background and totally new to DevOps, I want to setup <strong>consul for service discovery</strong> for my micro-services, services are reverse proxied by <strong>Nginx</strong>. Now I want to configure Nginx with the consul, we are not using dockers as of now.</p>
  
  <p>I have gone through many tutorials but I didn't get much about that how can I configure Nginx with the consul.</p>
  
  <p>Any lead would be appreciated.</p>
  
Comments: CC BY-SA 3.0
Comments: 2018-04-09T19:41:40.893Z
Comments: What tutorials?
Comments: 030
Comments: CC BY-SA 3.0
Comments: 2018-04-09T19:45:22.257Z
Comments: tutorials where I can setup consul with nginx, but all the examples are done using docker.
Comments: Ravat Tailor
Comments: CC BY-SA 3.0
Comments: 2018-04-09T19:46:41.473Z
Comments: OK, what URLs did you consult?
Comments: 030
Comments: CC BY-SA 3.0
Comments: 2018-04-09T19:49:10.640Z
Comments: https://ifritltd.com/2017/11/03/service-discovery-with-consul-registrator-nginx/
Comments: Ravat Tailor
Comments: CC BY-SA 3.0
Comments: 2018-04-09T19:49:14.023Z
Comments: https://www.nginx.com/blog/service-discovery-with-nginx-plus-and-consul/
Comments: Ravat Tailor
Comments: CC BY-SA 3.0
Comments: 2018-04-09T19:50:03.003Z
Comments: https://medium.com/@micheldlebeau/use-consul-as-a-load-balancer-with-nginx-b1f6f887677d
Comments: Ravat Tailor
Comments: CC BY-SA 3.0
Comments: 2018-04-09T19:50:41.787Z
Comments: You could add these URLs to the question
Comments: 030
Comments: CC BY-SA 3.0
Comments: 2018-04-09T19:51:58.903Z
Comments: apologize for that, will keep in mind in future
Comments: Ravat Tailor
Comments: CC BY-SA 3.0
Comments: 2018-04-09T19:53:34.863Z
Comments: @030, It would really be very helpful if can get the basic example of nginx and consul, because I have setup consul in my spring application,
Comments: Ravat Tailor
Tags: <microservices><nginx><consul>
Title: Consul with Nginx, not using docker
UserDisplayName: Ravat Tailor
ThreadText: # Consul with Nginx, not using docker
  
  (Asked by: username_0 on 2018-04-09)
  
  I am from development background and totally new to DevOps, I want to setup **consul for service discovery** for my micro-services, services are reverse proxied by **Nginx**. Now I want to configure Nginx with the consul, we are not using dockers as of now.
  
  I have gone through many tutorials but I didn't get much about that how can I configure Nginx with the consul.
  
  Any lead would be appreciated.
  
  **Tags:** microservices, nginx, consul
  
  > **Comments:**
  > **username_1**: What tutorials?  
  > **username_0**: tutorials where I can setup consul with nginx, but all the examples are done using docker.  
  > **username_1**: OK, what URLs did you consult?  
  > **username_0**: https://ifritltd.com/2017/11/03/service-discovery-with-consul-registrator-nginx/  
  > **username_0**: https://www.nginx.com/blog/service-discovery-with-nginx-plus-and-consul/  
  > **username_0**: https://medium.com/@micheldlebeau/use-consul-as-a-load-balancer-with-nginx-b1f6f887677d  
  > **username_1**: You could add these URLs to the question  
  > **username_0**: apologize for that, will keep in mind in future  
  > **username_0**: @username_1, It would really be very helpful if can get the basic example of nginx and consul, because I have setup consul in my spring application,  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_2 on 2018-04-09. Score: 2
  
  I have done this in the past using <https://github.com/hashicorp/consul-template>.
  
  What `consul-template` does it generate a configuration file (for nginx) based on a certain template you provide. And the values that it fills into this template are coming from the configuration stored in `consul`.
  
  Each time your micro-services register themselves in `consul` and need to be addressed in the nginx configuration file, `consul-template` does it for you by changing the file and sending a `SIGHUP` (`kill -1`) to the nginx process that makes it reload nginx configuration.
  
  The repository for `consule-template` contains an example of managing `nginx` <https://github.com/hashicorp/consul-template/blob/master/examples/nginx.md>
  
  ---
  
  If you are using *Nginx Plus*, which is the commercial version of Nginx. Then it has support for Consul built-in. <https://www.nginx.com/blog/service-discovery-with-nginx-plus-and-consul/> and <https://www.nginx.com/blog/service-discovery-nginx-plus-srv-records-consul-dns/> go into depth on this subject.
  
  > **Comments:**
  > **username_0**: I went through these tutorials but didn't get much help because all the things are new for me, means I am beginner in both consul and nginx, can you please provide me a simple basic example with both nginx and consul, I will be heartily thankful to you, because of this I am stuck from last 2 days  
  > **username_2**: Updated the answer to include a link to an example.  
  
  ---
  
  