-
Notifications
You must be signed in to change notification settings - Fork 0
/
ng-proxy.tmpl
68 lines (65 loc) · 2.23 KB
/
ng-proxy.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
# dynamical part by confd
{{range $spec := getvs "/registry/services/specs/*/*"}} {{$data := json $spec}} {{ if $data.metadata.annotations.kubernetesReverseproxy }} {{$p := json $data.metadata.annotations.kubernetesReverseproxy }}
{{range $proxy := $p.hosts}} {{if $proxy.host }}
# {{$proxy.host}}
server {
{{if $proxy.port }}
listen {{$proxy.port}}; {{end}}
server_name {{$proxy.host}};
{{if $proxy.ssl }}
ssl_certificate /etc/nginx/ssl/{{$proxy.sslCrt}};
ssl_certificate_key /etc/nginx/ssl/{{$proxy.sslKey}};
ssl on;
ssl_session_cache builtin:1000 shared:SSL:10m;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_ciphers HIGH:!aNULL:!eNULL:!EXPORT:!CAMELLIA:!DES:!MD5:!PSK:!RC4;
ssl_prefer_server_ciphers on;
{{ end }}
{{if $proxy.path }}
{{range $path := $proxy.path}}
location {{$path}}/ {
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_set_header X-NginX-Proxy true;
{{if $proxy.ssl }}
proxy_redirect http:// https://;
{{ else }}
proxy_redirect off;
{{ end }}
{{if $proxy.webSocket }}
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
{{ end }}
proxy_pass http://{{$data.spec.portalIP}}:{{$data.spec.port}};
}
{{ end }}
{{ if $proxy.defaultPath}}
location / {
rewrite ^/$ {{$proxy.defaultPath}}/ permanent;
}
{{ end }}
{{ else }}
location / {
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_set_header X-NginX-Proxy true;
{{if $proxy.ssl }}
proxy_redirect http:// https://;
{{ else }}
proxy_redirect off;
{{ end }}
{{if $proxy.webSocket }}
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
{{ end }}
{{range $svc_port := $data.spec.ports }}
proxy_pass http://{{$data.spec.portalIP}}:{{$svc_port.port}};
{{end}}
} {{ end }}
} {{ end }}
{{ end }} {{ end }} {{ end }}
# END od dynamical part by confd