Search code examples
nginxconsulnomad

Nomad : Health Check


need help I have this

service {
  name = "nginx"
  tags = [ "nginx", "web", "urlprefix-/nginx" ]
  port = "http"
  check {
    type = "tcp"
    interval = "10s"
    timeout = "2s"
  }
}

how can i add a health for a specific URI if it returns a 200 response like localhost:8080/test/index.html


Solution

  • It is as simple as adding another check configured to use an http check like so where /health is served by your nginx on its published port:

    service {
      name = "nginx"
      tags = [ "nginx", "web", "urlprefix-/nginx" ]
      port = "http"
      check {
        type = "tcp"
        interval = "10s"
        timeout = "2s"
      }
      check {
        type = "http"
        path = "/health"
        interval = "10s"
        timeout  = "2s"
      }
    }
    

    You can see a full example here: https://www.nomadproject.io/docs/job-specification/index.html