Skip to content

Instantly share code, notes, and snippets.

@langerma
Last active November 28, 2021 17:14
Show Gist options
  • Save langerma/082fbab71344daccf4e007e64e15fb45 to your computer and use it in GitHub Desktop.
Save langerma/082fbab71344daccf4e007e64e15fb45 to your computer and use it in GitHub Desktop.
traefik reverse proxy
job "traefik" {
datacenters = ["morsegasse"]
type = "system"
group "loadbalancers" {
#constraint {
# attribute = "${meta.worker}"
# value = "pine"
# }
count = 1
task "traefik" {
constraint {
attribute = "${attr.cpu.arch}"
value = "arm64"
}
driver = "docker"
config {
privileged = true
force_pull = true
image = "arm64v8/traefik"
hostname = "traefik"
args = [
"--api=true",
"--api.dashboard=true",
"--api.insecure=true",
"--log.format=json",
"--accesslog=true",
"--accesslog.format=json",
"--providers.consulcatalog=true",
"--providers.consulcatalog.endpoint.address=http://consul.service.consul:8500",
"--providers.consulcatalog.exposedByDefault=false",
"--providers.consulcatalog.defaultRule=Host(`{{ normalize .Name }}.service.consul`)",
"--entryPoints.redis.address=:6379/tcp",
"--entryPoints.postgres.address=:5432/tcp",
"--entryPoints.mqtt.address=:1883/tcp",
"--entryPoints.zookeeper.address=:2181/tcp",
"--entryPoints.http.address=:80",
"--metrics",
"--metrics.prometheus"
]
port_map {
http = 80
api = 8080
redis = 6379
mqtt = 1883
postgres = 5432
zookeeper = 2181
}
}
resources {
network {
port "http" { static = 80 }
port "api" { static = 8080 }
port "redis" { static = 6379 }
port "mqtt" { static = 1883 }
port "postgres" { static = 5432 }
port "zookeeper" { static = 2181 }
}
memory = 50
}
service {
name = "traefik-api"
port = "api"
tags = [
"traefik.enable=true",
"traefik.http.routers.api.rule=Host(`traefik-api.service.consul`)",
"traefik.http.routers.api.service=api@internal"
]
check {
type = "http"
path = "/"
interval = "5s"
timeout = "1s"
}
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment