dummy server properly configured, nginx configuration for dummy server too, I just need to verify that the nginx configuration is properly modified when dummy server replicas are added/removed (done: it works)

This commit is contained in:
LUXEY Adrien 2021-05-08 16:36:44 +02:00
parent fab59e7a7a
commit 560e1f1d90
4 changed files with 30 additions and 30 deletions

View file

@ -10,9 +10,14 @@
1. Base components: things that need to be installed before services
* [x] Dummy HTTP server to have something to work with.
* [x] Reverse-proxy/load-balancer: `nginx` is a good match for a one-node deployment. Installing it with Nomad/Consul will make me practice Consul Template etc.
* Generate services configuration outside the `nginx` service definition.
* TLS: Let's Encrypt will probably be part of the same job definition as `nginx`.
* [x] Reverse-proxy/load-balancer: nginx is a good match for a one-node deployment. Installing it with Nomad/Consul will make me practice Consul Template etc.
* [x] Generate services configuration outside the nginx service definition.
Can't do because of *separation of concerns*: files needed by nginx need to be defined in the nginx job specification.
Solution: each new service needs to add its nginx configuration to `app/nginx/config`.
* TLS: Let's Encrypt will probably be part of the same job definition as nginx.
2. Gitea migration

View file

@ -2,11 +2,6 @@ job "dummy-http-server" {
datacenters = ["dc1"]
group "server-group" {
count = 5
# update {
# canary = 1
# max_parallel = 5
# }
network {
port "http" {}
@ -27,6 +22,7 @@ job "dummy-http-server" {
driver = "docker"
config {
ports = ["http"]
image = "hashicorp/http-echo:latest"
args = [
"-listen", ":${NOMAD_PORT_http}",

View file

@ -0,0 +1,17 @@
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 80;
listen [::]:80;
server_name dummy.hammerhead.luxeylab.net;
location / {
proxy_pass http://dummy-http-server-backend;
}
}

View file

@ -6,7 +6,7 @@ job "nginx" {
network {
port "http" {
static = 8080
static = 80
}
}
@ -19,34 +19,16 @@ job "nginx" {
driver = "docker"
config {
image = "nginx"
ports = ["http"]
image = "nginx"
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"
data = file("../config/dummy-http-server.tpl")
destination = "local/dummy-http-server.conf"
change_mode = "signal"
change_signal = "SIGHUP"
}