From 44172ca5dea4e75a2e1fbaeb3a75df400f5327d3 Mon Sep 17 00:00:00 2001 From: Akshay Mankar Date: Wed, 27 Oct 2021 17:10:23 +0200 Subject: [PATCH 1/4] Allow nginz to serve deeplink --- changelog.d/2-features/nginz-deeplink | 1 + .../nginz/templates/conf/_deeplink.html.tpl | 12 +++++++++++ .../nginz/templates/conf/_deeplink.json.tpl | 21 +++++++++++++++++++ charts/nginz/templates/conf/_nginx.conf.tpl | 15 +++++++++++++ charts/nginz/templates/configmap.yaml | 4 ++++ charts/nginz/values.yaml | 9 ++++++++ 6 files changed, 62 insertions(+) create mode 100644 changelog.d/2-features/nginz-deeplink create mode 100644 charts/nginz/templates/conf/_deeplink.html.tpl create mode 100644 charts/nginz/templates/conf/_deeplink.json.tpl 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..6f19870f9c --- /dev/null +++ b/charts/nginz/templates/conf/_deeplink.html.tpl @@ -0,0 +1,12 @@ +{{- define "nginz_deeplink.html" }} + + + + {{- 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..d251b6d86a --- /dev/null +++ b/charts/nginz/templates/conf/_deeplink.json.tpl @@ -0,0 +1,21 @@ +{{- define "nginz_deeplink.json" }} +{{- if hasKey .Values.nginx_conf "deeplink" }} +{{- with .Values.nginx_conf.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 }} \ No newline at end of file diff --git a/charts/nginz/templates/conf/_nginx.conf.tpl b/charts/nginz/templates/conf/_nginx.conf.tpl index d5f888b2b7..b11335efc9 100644 --- a/charts/nginz/templates/conf/_nginx.conf.tpl +++ b/charts/nginz/templates/conf/_nginx.conf.tpl @@ -344,6 +344,21 @@ http { image/png png; } } + + {{- if hasKey .Values.nginx_conf "deeplink" }} + location ~* ^/deeplink.(json|html)$ { + zauth off; + root /etc/wire/nginz/conf/; + 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 From eacea8617fc6ce04ab4c760f33351d64cfb88c11 Mon Sep 17 00:00:00 2001 From: Akshay Mankar Date: Wed, 27 Oct 2021 17:23:06 +0200 Subject: [PATCH 2/4] Serve deeplink.json with the correct Content-Type --- charts/nginz/templates/conf/_nginx.conf.tpl | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/charts/nginz/templates/conf/_nginx.conf.tpl b/charts/nginz/templates/conf/_nginx.conf.tpl index b11335efc9..1e3d993704 100644 --- a/charts/nginz/templates/conf/_nginx.conf.tpl +++ b/charts/nginz/templates/conf/_nginx.conf.tpl @@ -349,6 +349,10 @@ http { 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"; From fb52d9a6fad172ec9f6af0c4d36c0cb9f7903db9 Mon Sep 17 00:00:00 2001 From: jschaul Date: Wed, 27 Oct 2021 19:20:46 +0200 Subject: [PATCH 3/4] fixup in deeplink.html --- charts/nginz/templates/conf/_deeplink.html.tpl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/charts/nginz/templates/conf/_deeplink.html.tpl b/charts/nginz/templates/conf/_deeplink.html.tpl index 6f19870f9c..33c69eccdf 100644 --- a/charts/nginz/templates/conf/_deeplink.html.tpl +++ b/charts/nginz/templates/conf/_deeplink.html.tpl @@ -3,7 +3,7 @@ {{- if hasKey .Values.nginx_conf "deeplink" }} - Click here for access + Click here for access {{- else }} No Deep Link. {{- end }} From 25e3baeff41b1845fa63ecd2aa5285d6d687da1e Mon Sep 17 00:00:00 2001 From: jschaul Date: Wed, 27 Oct 2021 19:26:03 +0200 Subject: [PATCH 4/4] Add comment pointing to the docs --- charts/nginz/templates/conf/_deeplink.html.tpl | 3 +++ charts/nginz/templates/conf/_deeplink.json.tpl | 5 ++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/charts/nginz/templates/conf/_deeplink.html.tpl b/charts/nginz/templates/conf/_deeplink.html.tpl index 33c69eccdf..4e9b458def 100644 --- a/charts/nginz/templates/conf/_deeplink.html.tpl +++ b/charts/nginz/templates/conf/_deeplink.html.tpl @@ -1,4 +1,7 @@ {{- 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*/}} diff --git a/charts/nginz/templates/conf/_deeplink.json.tpl b/charts/nginz/templates/conf/_deeplink.json.tpl index d251b6d86a..da5ddb19a6 100644 --- a/charts/nginz/templates/conf/_deeplink.json.tpl +++ b/charts/nginz/templates/conf/_deeplink.json.tpl @@ -1,6 +1,9 @@ {{- 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 }} @@ -18,4 +21,4 @@ {{- else }} {} {{- end }} -{{- end }} \ No newline at end of file +{{- end }}