Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
OLMIS-982: Change nginx image, introduce consul-template to query con…
…sul over time
- Loading branch information
Showing
5 changed files
with
84 additions
and
256 deletions.
There are no files selected for viewing
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
{{- $loaded_services := services -}} | ||
|
||
{{ range $loaded_services -}} | ||
{{ if in .Tags "openlmis-service" }} | ||
upstream {{ .Name }} { | ||
least_conn; | ||
{{ range service .Name }}server {{ .Address }}:{{ .Port }}; | ||
{{ end }} | ||
} | ||
{{ end }} | ||
{{- end }} | ||
|
||
server { | ||
listen 80; | ||
server_name {{ env "VIRTUAL_HOST" }}; | ||
{{ range $loaded_services -}} | ||
{{ if in .Tags "openlmis-service" }} | ||
{{ $location := .Name }} | ||
location /{{ $location }}/ { | ||
rewrite /{{ $location }}(.*)$ $1 break; | ||
proxy_pass http://{{ $location }}; | ||
} | ||
{{ end }} | ||
{{- end }} | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
#!/bin/sh | ||
|
||
# Run consul-template in background | ||
INPUT_FILE="/etc/consul-template/conf/nginx.conf" | ||
OUTPUT_FILE="/etc/nginx/conf.d/default.conf" | ||
CALLBACK="/etc/init.d/nginx reload" | ||
|
||
consul-template \ | ||
-consul "${CONSUL_HOST:=consul}:8500" \ | ||
-template "$INPUT_FILE:$OUTPUT_FILE:$CALLBACK" & | ||
|
||
# Run nginx | ||
nginx -g 'daemon off;' | ||
|
Those variables are used by Registrator (tracking this service isn't necessary, as consul always has itself included in service list, so this would be a duplicate record).