Skip to content

Instantly share code, notes, and snippets.

@odnanref
Created February 12, 2022 10:55
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save odnanref/0c3aeb0de203ab1a6a1b2ef51a613ca2 to your computer and use it in GitHub Desktop.
Save odnanref/0c3aeb0de203ab1a6a1b2ef51a613ca2 to your computer and use it in GitHub Desktop.
PiHole LoadBalance UDP and HTTP
job "pihole" {
datacenters = ["dc1"]
type = "service"
group "pihole" {
count = 1
volume "volume_nomad" {
type = "host"
read_only = false
source = "mysql"
}
network {
port "pihole" {
to = 53
}
port "http" {
to = 80
}
}
restart {
attempts = 10
interval = "5m"
delay = "25s"
mode = "delay"
}
task "pihole" {
driver = "docker"
volume_mount {
volume = "volume_nomad"
destination = "/etc/pihole/"
read_only = false
}
env {
TZ = "Europe/Lisbon"
WEBPASSWORD = "strong PASSWORD!!"
ADMIN_EMAIL = "webmaster@xxx.com"
PIHOLE_DNS_ = "1.1.1.1;8.8.8.8"
QUERY_LOGGING = "true"
}
config {
image = "pihole/pihole"
ports = [
"pihole",
"http"
]
}
resources {
cpu = 1000
memory = 128
}
service {
name = "pihole"
port = "pihole"
tags = [
"traefik.enable=true",
"traefik.tcp.routers.dns.rule=HostSNI(`*`)",
"traefik.tcp.routers.dns.entrypoints=pihole",
"traefik.tcp.routers.dns.service=pihole",
"traefik.tcp.services.pihole.loadbalancer.server.port=53",
"traefik.udp.routers.dns_udp.entrypoints=piholeudp",
"traefik.udp.routers.dns_udp.service=piholeudp",
"traefik.udp.services.piholeudp.loadbalancer.server.port=53"
]
check {
type = "tcp"
interval = "10s"
timeout = "2s"
}
}
service {
name = "piholehttp"
port = "http"
tags = [
"traefik.enable=true",
"traefik.protocol=http",
"traefik.http.routers.piholehttp.rule=Host(`pihole.a1.xxx.com`)",
"traefik.http.routers.piholehttp.entrypoints=web",
"traefik.http.services.piholehttp.loadbalancer.server.scheme=http"
]
check {
type = "tcp"
interval = "10s"
timeout = "2s"
}
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment