I have a go app that i need to run multiple instances under separate subdomains, i have a working nomad consul setup and got the go app to run and is accessible via a fixed ip address and dedicated port. But i am stuck on how to make it work with the unique subdomains and working https. So what i’m looking for is like
app1 runs on https://app1.example.com
app2 runs on https://app2.example.com
I tried to use traefic (got it running as a job), DNSmasq but i havent got the above to work.
The example in that tutorial configures the tag traefik.http.routers.http.rule=Path('/myapp') on the service so that requests for /myapp are routed to the backend service instance. In your case, you’ll need to modify this to match on the HTTP Host header instead. For example:
I still have one remaining issue:
So i have nomad / consul and traefic working. Ssl is working and domain names are working
My app makes use of the rtmp port 1935
This is my traefic nomad file is:
job 'traefic' {
region = "global"
datacenters = ["dc1"]
type = "system"
group "traefik" {
task "traefik" {
driver = "docker"
config {
image = "traefik:v2.2"
network_mode = "host"
volumes = [
"local/traefik.toml:/etc/traefik/traefik.toml",
]
}
template {
data = <<EOF
[entryPoints]
[entryPoints.http]
address = ":80"
[entryPoints.traefik]
address = ":8081"
[entryPoints.rtmp]
address = ":1935"
[entryPoints.websecure]
address = ":443"
[certificatesResolvers.myresolver.acme]
email = "bla@bla.eu"
storage = "acme.json"
[certificatesResolvers.myresolver.acme.httpChallenge]
# used during the challenge
entryPoint = "http"
[api]
dashboard = true
insecure = true# Enable Consul Catalog configuration backend.
[providers.consulCatalog]
prefix = "traefik"
exposedByDefault = false
[providers.consulCatalog.endpoint]
address = "127.0.0.1:8500"
scheme = "http"
EOF
destination = "local/traefik.toml"
}
resources {
cpu = 100
memory = 128
network {
port "http" {
static = 80
}
port "https" {
static = 443
}
port "api" {
static = 8081
}
}
}
service {
name = "traefik"
check {
name = "alive"
type = "tcp"
port = "http"
interval = "10s"
timeout = "2s"
}
}
}
}
}
and my app nomad file is
job "webapp" {
# Which region are you running your job
datacenters = ["dc1"]
type = "service"
group "web" {
count = 1
network {
port "frontendPort" { to = 8080 }
port "rtmpPort" { to = 1935 }
}
task "server" {
# The driver used to manage the containers
driver = "docker"
config {
# Image we want to pull
image = ".../..."
ports = ["frontendPort", "rtmpPort"]
}
service {
name = "webapp"
port = "frontendPort"
tags = [
"traefik.enable=true",
"traefik.http.routers.demowebapp2-https.tls=true",
"traefik.http.routers.demowebapp2-https.rule=Host(`......`)",
"traefik.http.routers.demowebapp2-https.tls.certresolver=myresolver",
"traefik.http.routers.demowebapp2-https.tls.domains[0].main=.....",
"traefik.http.routers.demowebapp2-http.rule=Host(`......`)",
]
check {
port = "frontendPort"
type = "http"
path = "/"
interval = "2s"
timeout = "2s"
}
}
}
}
}
RTMP uses TCP as the transport protocol. I believe you just need to add a few additional tags to your Nomad job spec to configure Traefik to route port 1935 to your application. Something like this might work.
but it still doenst resolve properly. I’ve read many other articles but nobody is explaining the use for rtmp, so weird.
I also added udp to the traefik toml file. this didnt help either.
I’m not sure why this isn’t working. Considering this is probably an issue with Traefik’s configuration, you might have better luck getting support for this on Traefik’s community forum at https://community.traefik.io/.