-
-
Notifications
You must be signed in to change notification settings - Fork 3
/
nginx.tmpl
28 lines (25 loc) · 980 Bytes
/
nginx.tmpl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
{{ range $service := ls "/services" }}
{{ if ls (printf "/services/%s/upstream" $service) }}
upstream {{ $service }}_pool {
{{ range getvs (printf "/services/%s/upstream/*" $service) }}
server {{ . }};
{{ end }}
}
{{ end }}
{{ end }}
server {
listen 80 default_server;
access_log /dev/stdout;
error_log /dev/stderr;
{{ range $service := ls "/services" }}
{{ if ls (printf "/services/%s/upstream" $service) }}
location {{ if exists (printf "/services/%s/location" $service) }}{{ getv (printf "/services/%s/location" $service) }}{{ else }}/{{ $service }}/{{ end }} {
proxy_pass http://{{ $service }}_pool{{ if exists (printf "/services/%s/path" $service) }}{{ getv (printf "/services/%s/path" $service) }}{{ end }};
proxy_redirect off;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
{{ end }}
{{ end }}
}