@@ -12,6 +12,21 @@ map $http_upgrade $proxy_connection {
12
12
'' '';
13
13
}
14
14
15
+ gzip_types text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript;
16
+
17
+ access_log /proc/self/fd/1;
18
+ error_log /proc/self/fd/2;
19
+
20
+ # HTTP 1.1 support
21
+ proxy_http_version 1.1;
22
+ proxy_buffering off;
23
+ proxy_set_header Host $http_host;
24
+ proxy_set_header Upgrade $http_upgrade;
25
+ proxy_set_header Connection $proxy_connection;
26
+ proxy_set_header X-Real-IP $remote_addr;
27
+ proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
28
+ proxy_set_header X-Forwarded-Proto $proxy_x_forwarded_proto;
29
+
15
30
server {
16
31
listen 80 default_server;
17
32
server_name _; # This is just an invalid value which will never trigger on a real hostname.
@@ -22,31 +37,27 @@ server {
22
37
23
38
{{ range $host, $containers := groupByMulti $ "Env.VIRTUAL_HOST" "," }}
24
39
upstream {{ $host }} {
25
-
26
- {{ range $index, $value := $containers }}
27
-
28
- {{ $addrLen := len $value.Addresses }}
40
+ {{ range $container := $containers }}
41
+ {{ $addrLen := len $container.Addresses }}
29
42
{{/* If only 1 port exposed, use that */}}
30
43
{{ if eq $addrLen 1 }}
31
- {{ with $address := index $value .Addresses 0 }}
32
- # {{$value .Name}}
44
+ {{ with $address := index $container .Addresses 0 }}
45
+ # {{$container .Name}}
33
46
server {{ $address.IP }}:{{ $address.Port }};
34
47
{{ end }}
35
-
36
48
{{/* If more than one port exposed, use the one matching VIRTUAL_PORT env var */}}
37
- {{ else if $value .Env.VIRTUAL_PORT }}
38
- {{ range $i, $ address := $value .Addresses }}
39
- {{ if eq $address.Port $value .Env.VIRTUAL_PORT }}
40
- # {{$value .Name}}
49
+ {{ else if $container .Env.VIRTUAL_PORT }}
50
+ {{ range $address := .Addresses }}
51
+ {{ if eq $address.Port $container .Env.VIRTUAL_PORT }}
52
+ # {{$container .Name}}
41
53
server {{ $address.IP }}:{{ $address.Port }};
42
54
{{ end }}
43
55
{{ end }}
44
-
45
56
{{/* Else default to standard web port 80 */}}
46
57
{{ else }}
47
- {{ range $i, $ address := $value .Addresses }}
58
+ {{ range $address := $container .Addresses }}
48
59
{{ if eq $address.Port "80" }}
49
- # {{$value .Name}}
60
+ # {{$container .Name}}
50
61
server {{ $address.IP }}:{{ $address.Port }};
51
62
{{ end }}
52
63
{{ end }}
@@ -55,24 +66,10 @@ upstream {{ $host }} {
55
66
}
56
67
57
68
server {
58
- gzip_types text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript;
59
-
60
69
server_name {{ $host }};
61
- proxy_buffering off;
62
- error_log /proc/self/fd/2;
63
- access_log /proc/self/fd/1;
64
70
65
71
location / {
66
72
proxy_pass http://{{ $host }};
67
- proxy_set_header Host $http_host;
68
- proxy_set_header X-Real-IP $remote_addr;
69
- proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
70
- proxy_set_header X-Forwarded-Proto $proxy_x_forwarded_proto;
71
-
72
- # HTTP 1.1 support
73
- proxy_http_version 1.1;
74
- proxy_set_header Upgrade $http_upgrade;
75
- proxy_set_header Connection $proxy_connection;
76
73
}
77
74
}
78
75
{{ end }}
0 commit comments