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