Files
nomad-nummer5/test/nginx-lb.hcl
2023-09-19 19:49:36 +02:00

56 lines
810 B
HCL

job "nginx" {
datacenters = ["dc1"]
group "nginx" {
count = 1
network {
port "http" {
static = 80
}
}
service {
name = "nginx"
port = "http"
}
task "nginx" {
driver = "podman"
config {
image = "docker.io/nginx"
ports = ["http"]
volumes = [
"local:/etc/nginx/conf.d",
]
}
template {
data = <<EOF
upstream backend {
{{ range service "demo-webapp" }}
server {{ .Address }}:{{ .Port }};
{{ else }}server 127.0.0.1:65535; # force a 502
{{ end }}
}
server {
listen 80;
location / {
proxy_pass http://backend;
}
}
EOF
destination = "local/load-balancer.conf"
change_mode = "signal"
change_signal = "SIGHUP"
}
}
}
}