Skip to content

Commit 14cac8b

Browse files
Allow configuring nginz so it serves the deeplink for apps to discover the backend (#1889)
Allow nginz to serve a deeplink (see also https://docs.wire.com/how-to/associate/deeplink.html ) Co-authored-by: jschaul <[email protected]>
1 parent f38428c commit 14cac8b

File tree

6 files changed

+72
-0
lines changed

6 files changed

+72
-0
lines changed

changelog.d/2-features/nginz-deeplink

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Allow configuring nginz so it serve the deeplink for apps to discover the backend
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{{- define "nginz_deeplink.html" }}
2+
{{/* See https://docs.wire.com/how-to/associate/deeplink.html
3+
(or search for "deeplink" on docs.wire.com)
4+
for details on use of the deeplink*/}}
5+
<html>
6+
<head></head>
7+
<body>
8+
{{- if hasKey .Values.nginx_conf "deeplink" }}
9+
<a href="wire://access/?config={{ .Values.nginx_conf.deeplink.endpoints.backendURL }}/deeplink.json">Click here for access</a>
10+
{{- else }}
11+
No Deep Link.
12+
{{- end }}
13+
</body>
14+
</html>
15+
{{- end }}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
{{- define "nginz_deeplink.json" }}
2+
{{- if hasKey .Values.nginx_conf "deeplink" }}
3+
{{- with .Values.nginx_conf.deeplink }}
4+
{{/* See https://docs.wire.com/how-to/associate/deeplink.html
5+
(or search for "deeplink" on docs.wire.com)
6+
for details on use of the deeplink*/}}
7+
{
8+
"endpoints" : {
9+
{{- with .endpoints }}
10+
"backendURL" : {{ .backendURL | quote }},
11+
"backendWSURL": {{ .backendWSURL | quote }},
12+
"blackListURL": {{ .blackListURL | quote }},
13+
"teamsURL": {{ .teamsURL | quote }},
14+
"accountsURL": {{ .accountsURL | quote }},
15+
"websiteURL": {{ .websiteURL | quote }}
16+
{{- end }}
17+
},
18+
"title" : {{ .title | quote }}
19+
}
20+
{{- end }}
21+
{{- else }}
22+
{}
23+
{{- end }}
24+
{{- end }}

charts/nginz/templates/conf/_nginx.conf.tpl

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -344,6 +344,25 @@ http {
344344
image/png png;
345345
}
346346
}
347+
348+
{{- if hasKey .Values.nginx_conf "deeplink" }}
349+
location ~* ^/deeplink.(json|html)$ {
350+
zauth off;
351+
root /etc/wire/nginz/conf/;
352+
types {
353+
application/json json;
354+
text/html html;
355+
}
356+
if ($request_method = 'OPTIONS') {
357+
add_header 'Access-Control-Allow-Methods' "GET, OPTIONS";
358+
add_header 'Access-Control-Allow-Headers' "$http_access_control_request_headers, DNT,X-Mx-ReqToken,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type";
359+
add_header 'Content-Type' 'text/plain; charset=UTF-8';
360+
add_header 'Content-Length' 0;
361+
return 204;
362+
}
363+
more_set_headers 'Access-Control-Allow-Origin: $http_origin';
364+
}
365+
{{- end }}
347366
}
348367
}
349368
{{- end }}

charts/nginz/templates/configmap.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@ data:
66
{{- include "nginz_upstreams.txt" . | indent 4 }}
77
zwagger-config.js: |2
88
{{- include "nginz_zwagger-config.js" . | indent 4 }}
9+
deeplink.json: |2
10+
{{- include "nginz_deeplink.json" . | indent 4 }}
11+
deeplink.html: |2
12+
{{- include "nginz_deeplink.html" . | indent 4 }}
913
{{ (.Files.Glob "conf/static/*").AsConfig | indent 2 }}
1014
kind: ConfigMap
1115
metadata:

charts/nginz/values.yaml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,15 @@ nginx_conf:
3232
worker_rlimit_nofile: 131072
3333
worker_connections: 65536
3434
swagger_root: /var/www/swagger
35+
# deeplink:
36+
# endpoints:
37+
# backendURL: "https://prod-nginz-https.wire.com"
38+
# backendWSURL: "https://prod-nginz-ssl.wire.com"
39+
# blackListURL: "https://clientblacklist.wire.com/prod"
40+
# teamsURL: "https://teams.wire.com"
41+
# accountsURL: "https://accounts.wire.com"
42+
# websiteURL: "https://wire.com"
43+
# title: "Production"
3544
disabled_paths:
3645
- /conversations/last-events
3746
- ~* ^/conversations/([^/]*)/knock

0 commit comments

Comments
 (0)