-
Notifications
You must be signed in to change notification settings - Fork 6
/
nginx.ctmpl
44 lines (37 loc) · 1.07 KB
/
nginx.ctmpl
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
events {
worker_connections 1024;
}
http {
{{range $index, $service := services}}{{range $tag, $services := service $service.Name | byTag}}{{if eq "http" $tag}}
upstream {{$service.Name}} {
least_conn;
{{range $services}}server {{.Address}}:{{.Port}} max_fails=3 fail_timeout=60 weight=1;
{{end}}
}
server {
listen 80;
server_name {{$service.Name}}.*;
client_max_body_size 0;
set $forward_proto $scheme;
if ( $http_x_forwarded_proto != "" ) {
set $forward_proto $http_x_forwarded_proto;
}
location / {
proxy_pass http://{{$service.Name}};
proxy_redirect http://{{$service.Name}}/ /;
proxy_set_header X-Forwarded-Host $http_host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-Proto $forward_proto;
}
}
{{end}}{{end}}{{end}}
server {
listen 80 default_server;
location / {
root /www;
index index.html index.htm Default.htm;
}
}
}