diff --git a/changelog.d/2-features/nginz-deeplink b/changelog.d/2-features/nginz-deeplink new file mode 100644 index 0000000000..67ca834d7f --- /dev/null +++ b/changelog.d/2-features/nginz-deeplink @@ -0,0 +1 @@ +Allow configuring nginz so it serve the deeplink for apps to discover the backend \ No newline at end of file diff --git a/charts/nginz/templates/conf/_deeplink.html.tpl b/charts/nginz/templates/conf/_deeplink.html.tpl new file mode 100644 index 0000000000..4e9b458def --- /dev/null +++ b/charts/nginz/templates/conf/_deeplink.html.tpl @@ -0,0 +1,15 @@ +{{- define "nginz_deeplink.html" }} +{{/* See https://docs.wire.com/how-to/associate/deeplink.html + (or search for "deeplink" on docs.wire.com) + for details on use of the deeplink*/}} + + + + {{- if hasKey .Values.nginx_conf "deeplink" }} + Click here for access + {{- else }} + No Deep Link. + {{- end }} + + +{{- end }} diff --git a/charts/nginz/templates/conf/_deeplink.json.tpl b/charts/nginz/templates/conf/_deeplink.json.tpl new file mode 100644 index 0000000000..da5ddb19a6 --- /dev/null +++ b/charts/nginz/templates/conf/_deeplink.json.tpl @@ -0,0 +1,24 @@ +{{- define "nginz_deeplink.json" }} +{{- if hasKey .Values.nginx_conf "deeplink" }} +{{- with .Values.nginx_conf.deeplink }} +{{/* See https://docs.wire.com/how-to/associate/deeplink.html + (or search for "deeplink" on docs.wire.com) + for details on use of the deeplink*/}} +{ + "endpoints" : { + {{- with .endpoints }} + "backendURL" : {{ .backendURL | quote }}, + "backendWSURL": {{ .backendWSURL | quote }}, + "blackListURL": {{ .blackListURL | quote }}, + "teamsURL": {{ .teamsURL | quote }}, + "accountsURL": {{ .accountsURL | quote }}, + "websiteURL": {{ .websiteURL | quote }} + {{- end }} + }, + "title" : {{ .title | quote }} +} +{{- end }} +{{- else }} +{} +{{- end }} +{{- end }} diff --git a/charts/nginz/templates/conf/_nginx.conf.tpl b/charts/nginz/templates/conf/_nginx.conf.tpl index d5f888b2b7..1e3d993704 100644 --- a/charts/nginz/templates/conf/_nginx.conf.tpl +++ b/charts/nginz/templates/conf/_nginx.conf.tpl @@ -344,6 +344,25 @@ http { image/png png; } } + + {{- if hasKey .Values.nginx_conf "deeplink" }} + location ~* ^/deeplink.(json|html)$ { + zauth off; + root /etc/wire/nginz/conf/; + types { + application/json json; + text/html html; + } + if ($request_method = 'OPTIONS') { + add_header 'Access-Control-Allow-Methods' "GET, OPTIONS"; + 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"; + add_header 'Content-Type' 'text/plain; charset=UTF-8'; + add_header 'Content-Length' 0; + return 204; + } + more_set_headers 'Access-Control-Allow-Origin: $http_origin'; + } + {{- end }} } } {{- end }} diff --git a/charts/nginz/templates/configmap.yaml b/charts/nginz/templates/configmap.yaml index b14e4042ec..cb57148817 100644 --- a/charts/nginz/templates/configmap.yaml +++ b/charts/nginz/templates/configmap.yaml @@ -6,6 +6,10 @@ data: {{- include "nginz_upstreams.txt" . | indent 4 }} zwagger-config.js: |2 {{- include "nginz_zwagger-config.js" . | indent 4 }} + deeplink.json: |2 +{{- include "nginz_deeplink.json" . | indent 4 }} + deeplink.html: |2 +{{- include "nginz_deeplink.html" . | indent 4 }} {{ (.Files.Glob "conf/static/*").AsConfig | indent 2 }} kind: ConfigMap metadata: diff --git a/charts/nginz/values.yaml b/charts/nginz/values.yaml index 2d006ddb7b..5c0f7ebd81 100644 --- a/charts/nginz/values.yaml +++ b/charts/nginz/values.yaml @@ -32,6 +32,15 @@ nginx_conf: worker_rlimit_nofile: 131072 worker_connections: 65536 swagger_root: /var/www/swagger + # deeplink: + # endpoints: + # backendURL: "https://prod-nginz-https.wire.com" + # backendWSURL: "https://prod-nginz-ssl.wire.com" + # blackListURL: "https://clientblacklist.wire.com/prod" + # teamsURL: "https://teams.wire.com" + # accountsURL: "https://accounts.wire.com" + # websiteURL: "https://wire.com" + # title: "Production" disabled_paths: - /conversations/last-events - ~* ^/conversations/([^/]*)/knock