-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathnginx.tmpl
68 lines (56 loc) · 1.78 KB
/
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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
{{ range $path, $containers := groupByMulti $ "Env.VIRTUAL_PATH" "," }}
upstream {{ $path }} {
{{ range $index, $value := $containers }}
{{ $addrLen := len $value.Addresses }}
{{/* If only 1 port exposed, use that */}}
{{ if eq $addrLen 1 }}
{{ with $address := index $value.Addresses 0 }}
# {{$value.Name}}
server {{ $address.IP }}:{{ $address.Port }};
{{ end }}
{{/* If more than one port exposed, use the one matching VIRTUAL_PORT env var */}}
{{ else if $value.Env.VIRTUAL_PORT }}
{{ range $i, $address := $value.Addresses }}
{{ if eq $address.Port $value.Env.VIRTUAL_PORT }}
# {{$value.Name}}
server {{ $address.IP }}:{{ $address.Port }};
{{ end }}
{{ end }}
{{/* Else default to standard web port 80 */}}
{{ else }}
{{ range $i, $address := $value.Addresses }}
{{ if eq $address.Port "80" }}
# {{$value.Name}}
server {{ $address.IP }}:{{ $address.Port }};
{{ end }}
{{ end }}
{{ end }}
{{ end }}
}
{{ end }}
server {
listen 80;
server_name www.themburkes.com;
return 301 https://www.themburkes.com$request_uri;
}
server {
listen 443 ssl;
ssl on;
server_name www.themburkes.com;
ssl_certificate /etc/nginx/ssl/themburkes.com.crt;
ssl_certificate_key /etc/nginx/ssl/themburkes.com.key;
gzip_types text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript;
client_max_body_size 256M;
proxy_buffering off;
error_log /proc/self/fd/2;
access_log /proc/self/fd/1;
{{ range $path, $containers := groupByMulti $ "Env.VIRTUAL_PATH" "," }}
location /{{ $path }} {
proxy_pass http://{{ $path }};
include /etc/nginx/proxy_params;
# HTTP 1.1 support
proxy_http_version 1.1;
proxy_set_header Connection "";
}
{{ end }}
}