This repository has been archived by the owner on Jul 27, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 29
/
Copy pathnginx.tmpl
257 lines (214 loc) · 8.91 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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
worker_processes 1;
error_log /dev/stderr;
events {
worker_connections 1024;
}
{{$SSL := or (key "config/mantlui/ssl") (or (env "MANTLUI_SSL") "false") | parseBool}}
{{$AUTH := or (key "config/mantl/auth") (or (env "MANTLUI_AUTH") "false") | parseBool}}
{{$consulSSL := or (key "config/mantl/consul_ssl") (or (env "CONSUL_SSL") "false") | parseBool}}
http {
include mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout 65;
access_log /dev/stdout;
{{$mesos := service "leader.mesos" "any"}}{{with $mesos}}
upstream mesos { {{range $mesos}}
server {{.Address}}:{{.Port}};{{end}}
} {{end}}
{{$marathon := service "marathon" "any"}}{{with $marathon}}
upstream marathon { {{range $marathon}}
server {{.Address}}:{{.Port}};{{end}}
} {{end}}
{{$kubernetes_ui := service "nodeport" "any"}}{{with $kubernetes_ui}}
upstream kubernetes_ui { {{range $kubernetes_ui}}
server {{.Address}}:30000;{{end}}
} {{end}}
{{$kubernetes_api := service "kubernetes" "any"}}{{with $kubernetes_api}}
upstream kubernetes_api { {{range $kubernetes_api}}
server {{.Address}}:{{.Port}};{{end}}
} {{end}}
{{$chronos := service "chronos" "any"}}{{with $chronos}}
upstream chronos { {{range $chronos}}
server {{.Address}}:{{.Port}};{{end}}
} {{end}}
{{$consul := service "consul" "any"}}{{with $consul}}
upstream consul { {{range $consul}}
server {{.Address}}:8500;{{end}}
} {{end}}
{{$mantlapi := service "mantl-api" "any"}}{{with $mantlapi}}
upstream mantlapi { {{range $mantlapi}}
server {{.Address}}:{{.Port}};{{end}}
} {{end}}
{{$traefikAdmin := service "traefik-admin" "any"}}{{with $traefikAdmin}}
upstream traefik-admin { {{range $traefikAdmin}}
server {{.Address}}:{{.Port}};{{end}}
} {{end}}
{{$kibana := (or (service "kibana-mantl-task" "any") (service "kibana-mantl" "any") (service "kibana" "any"))}}{{with $kibana}}
upstream kibana { {{range $kibana}}
server {{.Address}}:{{.Port}};{{end}}
} {{end}}
{{$elasticsearch := (or (service "elasticsearch-mantl" "any") (service "elasticsearch" "any"))}}{{with $elasticsearch}}
upstream elasticsearch { {{range $elasticsearch}}
server {{.Address}}:{{.Port}};{{end}}
} {{end}}
{{$kafka_api := service "kafka-mantl" "any"}}{{with $kafka_api}}
upstream kafka-api { {{range $kafka_api}}
server {{.Address}}:{{.Port}};{{end}}
} {{end}}
{{if $SSL}}
server {
listen 80;
return 301 https://$host$request_uri;
}
{{end}}
server {
listen {{if $SSL}}443 ssl{{else}}80{{end}};
{{if $SSL}}
ssl_certificate {{or (env "CERTFILE") "/etc/nginx/ssl/nginx.cert"}};
ssl_certificate_key {{or (env "KEYFILE") "/etc/nginx/ssl/nginx.key"}};
ssl on;
ssl_session_cache builtin:1000 shared:SSL:10m;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_ciphers {{or (key "config/mantlui/ssl_ciphers") "HIGH:!aNULL:!eNULL:!EXPORT:!CAMELLIA:!DES:!MD5:!PSK:!RC4"}};
ssl_prefer_server_ciphers on;
error_page 497 https://$host:$server_port$request_uri;
{{end}}
{{if $AUTH}}
auth_basic on;
auth_basic_user_file /etc/nginx/nginx-auth.conf;
{{end}}
location / {
proxy_connect_timeout 600;
proxy_send_timeout 600;
proxy_read_timeout 600;
send_timeout 600;
root /usr/share/nginx/html;
index index.html index.htm;
try_files $uri $uri/ =404;
}
{{with $mesos}}
location = /mesos {
return 301 /mesos/;
}
location = /mesos/ {
root /usr/share/nginx/html;
}
location /mesos {
try_files $uri @mesos-upstream;
root /usr/share/nginx/html;
}
location @mesos-upstream {
proxy_set_header host $host;
proxy_set_header x-real-ip $remote_addr;
proxy_set_header x-forwarded-for $proxy_add_x_forwarded_for;
proxy_set_header x-forwarded-proto $scheme;
rewrite /mesos/(.+)$ /$1 break;
proxy_pass http://mesos;
} {{end}}
{{range service "agent.mesos" "any"}}
location ~ /mesos/slave/{{index (.ID | split ":") 2}}/(.*) {
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_pass http://{{.Address}}:{{.Port}}/$1$is_args$args;
}{{end}}
{{with $marathon}}
location /marathon/ {
proxy_set_header host $host;
proxy_set_header x-real-ip $remote_addr;
proxy_set_header x-forwarded-for $proxy_add_x_forwarded_for;
proxy_set_header x-forwarded-proto $scheme;
proxy_pass http://marathon/;
} {{end}}
{{with $kubernetes_ui}}
location /kubernetes/ {
proxy_set_header host $host;
proxy_set_header x-real-ip $remote_addr;
proxy_set_header x-forwarded-for $proxy_add_x_forwarded_for;
proxy_set_header x-forwarded-proto $scheme;
proxy_pass http://kubernetes_ui/;
} {{end}}
{{with $kubernetes_api}}
location /kubeapi/ {
proxy_set_header host $host;
proxy_set_header x-real-ip $remote_addr;
proxy_set_header x-forwarded-for $proxy_add_x_forwarded_for;
proxy_set_header x-forwarded-proto $scheme;
proxy_pass https://kubernetes_api/;
} {{end}}
{{with $chronos}}
location /chronos/ {
proxy_set_header host $host;
proxy_set_header x-real-ip $remote_addr;
proxy_set_header x-forwarded-for $proxy_add_x_forwarded_for;
proxy_set_header x-forwarded-proto $scheme;
proxy_pass http://chronos/;
} {{end}}
{{with $consul}}
location ~ /consul/(v1\/.*) {
proxy_set_header host $host;
proxy_set_header x-real-ip $remote_addr;
proxy_set_header x-forwarded-for $proxy_add_x_forwarded_for;
proxy_set_header x-forwarded-proto $scheme;
proxy_pass {{if $consulSSL}}https{{else}}http{{end}}://consul/$1$is_args$args;
} {{end}}
location /consul {
root /usr/share/nginx/html;
index index.html index.htm;
try_files $uri $uri/ =404;
}
{{with $mantlapi}}
location /api/ {
proxy_set_header host $host;
proxy_set_header x-real-ip $remote_addr;
proxy_set_header x-forwarded-for $proxy_add_x_forwarded_for;
proxy_set_header x-forwarded-proto $scheme;
proxy_pass http://mantlapi/;
} {{end}}
{{with $traefikAdmin}}
location = /traefik {
return 301 /traefik/dashboard/;
}
location /traefik {
try_files $uri $uri/ @traefik-upstream;
index index.html;
root /usr/share/nginx/html;
}
location @traefik-upstream {
proxy_set_header host $host;
proxy_set_header x-real-ip $remote_addr;
proxy_set_header x-forwarded-for $proxy_add_x_forwarded_for;
proxy_set_header x-forwarded-proto $scheme;
rewrite /traefik/(.+)$ /$1 break;
proxy_pass https://traefik-admin;
}
{{end}}
{{with $elasticsearch}}
location /elasticsearch/ {
proxy_set_header host $host;
proxy_set_header x-real-ip $remote_addr;
proxy_set_header x-forwarded-for $proxy_add_x_forwarded_for;
proxy_set_header x-forwarded-proto $scheme;
proxy_pass http://elasticsearch/;
} {{end}}
{{with $kibana}}
location /kibana {
proxy_set_header host $host;
proxy_set_header x-real-ip $remote_addr;
proxy_set_header x-forwarded-for $proxy_add_x_forwarded_for;
proxy_set_header x-forwarded-proto $scheme;
rewrite /kibana/(.+)$ /$1 break;
proxy_pass http://kibana/;
} {{end}}
{{with $kafka_api}}
location /kafka/ {
proxy_set_header host $host;
proxy_set_header x-real-ip $remote_addr;
proxy_set_header x-forwarded-for $proxy_add_x_forwarded_for;
proxy_set_header x-forwarded-proto $scheme;
proxy_pass http://kafka-api/;
} {{end}}
}
}