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.


1 Answer 1


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.

  • 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 Apr 9, 2018 at 10:29
  • Updated the answer to include a link to an example. Apr 9, 2018 at 11:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.