Skip to content

Instantly share code, notes, and snippets.

@lgfa29
Created April 15, 2021 01:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lgfa29/25dbd35a5231491f20cd06ad49a2525f to your computer and use it in GitHub Desktop.
Save lgfa29/25dbd35a5231491f20cd06ad49a2525f to your computer and use it in GitHub Desktop.
job "traefik" {
region = "global"
datacenters = ["dc1"]
type = "service"
group "traefik" {
count = 1
network {
port "http" {
static = 8080
}
port "api" {
static = 8081
}
}
service {
name = "traefik"
check {
name = "alive"
type = "tcp"
port = "http"
interval = "10s"
timeout = "2s"
}
}
task "traefik" {
driver = "docker"
config {
image = "traefik:v2.2"
ports = ["api", "http"]
volumes = [
"local/traefik.toml:/etc/traefik/traefik.toml",
]
}
template {
data = <<EOF
[entryPoints]
[entryPoints.http]
address = ":8080"
[entryPoints.traefik]
address = ":8081"
[api]
dashboard = true
insecure = true
[providers]
[providers.file]
directory = "/etc/traefik"
[http]
[http.routers]
[http.routers.http]
rule = "Path(`/myapp`)"
service = "demo-webapp"
[http.services]
[http.services.demo-webapp.loadBalancer]
{{ range service "demo-webapp" }}
[[http.services.demo-webapp.loadBalancer.servers]]
url = "http://host.docker.internal:{{ .Port }}/"
{{ end }}
EOF
destination = "local/traefik.toml"
}
resources {
cpu = 100
memory = 128
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment