From 560e1f1d90812b0a685d09b46ae70b62c52414e1 Mon Sep 17 00:00:00 2001 From: LUXEY Adrien Date: Sat, 8 May 2021 16:36:44 +0200 Subject: [PATCH] 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) --- hammerhead/README.md | 11 +++++--- .../deploy/dummy-http-server.hcl | 6 +---- .../app/nginx/config/dummy-http-server.tpl | 17 ++++++++++++ hammerhead/app/nginx/deploy/nginx.hcl | 26 +++---------------- 4 files changed, 30 insertions(+), 30 deletions(-) create mode 100644 hammerhead/app/nginx/config/dummy-http-server.tpl diff --git a/hammerhead/README.md b/hammerhead/README.md index 9580abe..4df8c4c 100644 --- a/hammerhead/README.md +++ b/hammerhead/README.md @@ -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 diff --git a/hammerhead/app/dummy-http-server/deploy/dummy-http-server.hcl b/hammerhead/app/dummy-http-server/deploy/dummy-http-server.hcl index f897023..8d738c6 100644 --- a/hammerhead/app/dummy-http-server/deploy/dummy-http-server.hcl +++ b/hammerhead/app/dummy-http-server/deploy/dummy-http-server.hcl @@ -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}", diff --git a/hammerhead/app/nginx/config/dummy-http-server.tpl b/hammerhead/app/nginx/config/dummy-http-server.tpl new file mode 100644 index 0000000..700809e --- /dev/null +++ b/hammerhead/app/nginx/config/dummy-http-server.tpl @@ -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; + } +} \ No newline at end of file diff --git a/hammerhead/app/nginx/deploy/nginx.hcl b/hammerhead/app/nginx/deploy/nginx.hcl index 535fb2e..a6dcdd4 100644 --- a/hammerhead/app/nginx/deploy/nginx.hcl +++ b/hammerhead/app/nginx/deploy/nginx.hcl @@ -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 = <