99 lines
2.3 KiB
HCL
99 lines
2.3 KiB
HCL
job "nginx" {
|
|
datacenters = ["dc1"]
|
|
type = "service"
|
|
group "nginx" {
|
|
count = 1
|
|
|
|
task "nginx" {
|
|
driver = "docker"
|
|
|
|
config {
|
|
image = "nginx"
|
|
ports = ["http"]
|
|
|
|
volumes = [
|
|
"custom/default.conf:/etc/nginx/conf.d/default.conf",
|
|
]
|
|
}
|
|
|
|
template {
|
|
data = <<EOH
|
|
server {
|
|
listen 8080;
|
|
server_name nginx.service.dc1.consul;
|
|
location / {
|
|
root /local/data;
|
|
}
|
|
}
|
|
EOH
|
|
|
|
destination = "custom/default.conf"
|
|
}
|
|
|
|
template {
|
|
data = <<EOH
|
|
<p>Local Services - HTTP/HTTPS</p>
|
|
<table style="width:100%">
|
|
<tr>
|
|
<th>Service Name</th>
|
|
<th>Traefik</th>
|
|
<th>Direct</th>
|
|
</tr>
|
|
{{range services}}
|
|
{{range $i, $s :=service .Name}}
|
|
{{ if eq $i 0 }}
|
|
|
|
<tr>
|
|
<td>{{.Name}}</td>
|
|
<td><a href="{{ if eq .Name "unifi" }}https{{else}}http{{end}}://{{.Name}}.service.dc1.consul" target="_blank">{{.Name}}.service.dc1.consul</a></td>
|
|
<td><a href="{{ if eq .Name "unifi" }}https{{else}}http{{end}}://{{.Name}}.service.dc1.consul:{{.Port}}" target="_blank">{{ if eq .Name "unifi" }}https{{else}}http{{end}}://{{.Name}}.service.dc1.consul:{{.Port}}</a></td>
|
|
</tr>
|
|
{{end}}
|
|
{{end}}
|
|
{{end}}
|
|
</table>
|
|
<p>
|
|
Node Environment Information: <br />
|
|
node_id: {{ env "node.unique.id" }} <br/>
|
|
datacenter: {{ env "NOMAD_DC" }}
|
|
</p>
|
|
EOH
|
|
|
|
destination = "local/data/index.html"
|
|
change_mode = "noop"
|
|
}
|
|
|
|
resources {
|
|
cpu = 100 # 100 MHz
|
|
memory = 64 # 128 MB
|
|
}
|
|
service {
|
|
name = "nginx"
|
|
tags = ["nginx", "web", "urlprefix-/nginx", "backend",
|
|
"traefik.http.routers.nginxlan.rule=Host(`nginx.service.dc1.consul`)",
|
|
"traefik.http.routers.nginxwan.rule=Host(`nginx.service.dc1.fbleagh.duckdns.org`)",
|
|
"traefik.http.routers.nginxwan.tls=true",
|
|
|
|
]
|
|
port = "http"
|
|
|
|
check {
|
|
type = "tcp"
|
|
interval = "10s"
|
|
timeout = "2s"
|
|
}
|
|
}
|
|
}
|
|
|
|
network {
|
|
port "http" {
|
|
to = 8080
|
|
}
|
|
|
|
// port "https" {
|
|
// to = 443
|
|
// }
|
|
}
|
|
}
|
|
}
|