Add blocky dns

This commit is contained in:
IamTheFij 2022-02-28 12:07:34 -08:00
parent 449a5061bc
commit 6110e78edf
4 changed files with 122 additions and 0 deletions

74
nomad/blocky/blocky.nomad Normal file
View File

@ -0,0 +1,74 @@
variable "config_data" {
type = string
description = "Plain text config file for blocky"
}
variable "base_hostname" {
type = string
description = "Base hostname to serve content from"
default = "dev.homelab"
}
job "blocky" {
datacenters = ["dc1"]
type = "service"
group "blocky" {
count = 1
network {
mode = "bridge"
port "dns" {
static = "53"
}
port "web" {
to = "4000"
}
}
service {
name = "dns"
port = "dns"
}
service {
name = "web"
port = "web"
tags = [
"traefik.enable=true",
"traefik.consulcatalog.connect=false",
"traefik.http.routers.blocky.entrypoints=web,websecure",
"traefik.http.routers.blocky.rule=Host(`blocky.${var.base_hostname}`)",
"traefik.http.routers.blocky.tls=true",
]
}
task "main" {
driver = "docker"
config {
image = "ghcr.io/0xerr0r/blocky"
ports = ["dns", "web"]
mount {
type = "bind"
target = "/app/config.yml"
source = "app/config.yml"
}
}
resources {
cpu = 50
memory = 100
}
template {
data = var.config_data
destination = "app/config.yml"
}
}
}
}

21
nomad/blocky/blocky.tf Normal file
View File

@ -0,0 +1,21 @@
variable "base_hostname" {
type = string
description = "Base hostname to serve content from"
default = "dev.homelab"
}
locals {
config_data = file("${path.module}/config.yml")
}
resource "nomad_job" "blocky" {
hcl2 {
enabled = true
vars = {
"config_data" = "${local.config_data}",
"base_hostname" = "${var.base_hostname}",
}
}
jobspec = file("${path.module}/blocky.nomad")
}

21
nomad/blocky/config.yml Normal file
View File

@ -0,0 +1,21 @@
upstream:
default:
- 1.1.1.1
- 1.0.0.1
blocking:
blackLists:
ads:
- https://raw.githubusercontent.com/StevenBlack/hosts/master/hosts
clientGroupsBlock:
default:
- ads
customDNS:
customTTL: 1h
mapping:
# TODO: Use a variable for this
dev.homelab: 192.168.2.41
port: 53
httpPort: 4000

View File

@ -38,6 +38,12 @@ module "mysql-server" {
base_hostname = var.base_hostname
}
module "blocky" {
source = "./blocky"
base_hostname = var.base_hostname
}
module "traefik" {
source = "./traefik"