I am following this blog " Traefik Proxy Now Fully Integrates with Hashicorp Nomad", where things are mostly working for me, but at the end I got 502 bad gateway error. Here's my job config:
job "traefik" {
datacenters = ["dc1"]
type = "service"
group "traefik" {
count = 1
network {
port "http"{
static = 80
}
port "admin"{
static = 8080
}
}
service {
name = "traefik-http"
provider = "nomad"
port = "http"
}
task "traefik" {
driver = "docker"
config {
image = "traefik:latest"
ports = ["admin", "http"]
args = [
"--api.dashboard=true",
"--api.insecure=true", ### For Test only, please do not use that in production
"--entrypoints.http.address=:${NOMAD_PORT_http}",
"--entrypoints.traefik.address=:${NOMAD_PORT_admin}",
"--providers.nomad=true",
"--providers.nomad.endpoint.address=http://host.docker.internal:4646" ### IP to your nomad server
]
}
}
}
}
and
job "whoami" {
datacenters = ["dc1"]
type = "service"
group "demo" {
count = 1
network {
port "http" {
to = 80
}
}
service {
name = "whoami-demo"
port = "http"
provider = "nomad"
tags = [
"traefik.enable=true",
"traefik.http.routers.http.rule=Path(`/whoami`)",
]
}
task "server" {
env {
WHOAMI_PORT_NUMBER = "${NOMAD_PORT_http}"
}
driver = "docker"
config {
image = "traefik/whoami"
ports = ["http"]
}
}
}
}
The routers and services all show up in the traefik dashboard, and i can access the whoami service at the actual port, e.g. http://127.0.0.1:20218/, but when i tried to get to it using the router, e.g. http://127.0.0.1/whoami, i got 502 bad gateway. Can someone shed some time?