From 307c4ebb242292d262459953b47003de88afec50 Mon Sep 17 00:00:00 2001
From: Mart van Santen <mart@greenhost.nl>
Date: Tue, 22 Mar 2022 17:51:37 +0800
Subject: [PATCH] Added web and kratos redirect

---
 deployment/helmchart/templates/ingress.yaml | 24 +++++++++++++++++----
 1 file changed, 20 insertions(+), 4 deletions(-)

diff --git a/deployment/helmchart/templates/ingress.yaml b/deployment/helmchart/templates/ingress.yaml
index 11cbbc16..7cc2b8eb 100644
--- a/deployment/helmchart/templates/ingress.yaml
+++ b/deployment/helmchart/templates/ingress.yaml
@@ -19,6 +19,7 @@ metadata:
     kubernetes.io/tls-acme: "true"
   {{- end }}
   {{- end }}
+    nginx.ingress.kubernetes.io/rewrite-target: /$1
 spec:
   {{- if or .Values.ingress.tls .Values.ingress.extraTls }}
   tls:
@@ -36,28 +37,43 @@ spec:
     - host: {{ .Values.ingress.hostname }}
       http:
         paths:
-          - path: {{ .Values.ingress.path }}
+          - path: ({{ .Values.ingress.path }}.*)
             {{- if eq "true" (include "common.ingress.supportsPathType" .) }}
             pathType: {{ .Values.ingress.pathType }}
             {{- end }}
             backend: {{- include "common.ingress.backend" (dict "serviceName" (include "dashboard.serviceName" .) "servicePort" "dashboard-http" "context" $)  | nindent 14 }}
           # Forward API calls to the back-end container
-          - path: {{ .Values.ingress.path }}api/v1
+          - path: ({{ .Values.ingress.path }}api/v1.*)
             {{- if eq "true" (include "common.ingress.supportsPathType" .) }}
             pathType: {{ .Values.ingress.pathType }}
             {{- end }}
             backend: {{- include "common.ingress.backend" (dict "serviceName" (include "backend.serviceName" .) "servicePort" "backend-http" "context" $)  | nindent 14 }}
+          - path: ({{ .Values.ingress.path }}web.*)
+            {{- if eq "true" (include "common.ingress.supportsPathType" .) }}
+            pathType: {{ .Values.ingress.pathType }}
+            {{- end }}
+            backend: {{- include "common.ingress.backend" (dict "serviceName" (include "backend.serviceName" .) "servicePort" "backend-http" "context" $)  | nindent 14 }}
+          - path: {{ .Values.ingress.path }}kratos/(.*)
+            {{- if eq "true" (include "common.ingress.supportsPathType" .) }}
+            pathType: {{ .Values.ingress.pathType }}
+            {{- end }}
+            backend: {{- include "common.ingress.backend" (dict "serviceName" (include "single-sign-on.fullname" .)-kratos-public "servicePort" "80" "context" $)  | nindent 14 }}
     {{- end }}
     {{- range .Values.ingress.extraHosts }}
     - host: {{ .name }}
       http:
         paths:
-          - path: {{ default "/" .path }}
+          - path: ({{ default "/" .path }}.*)
             {{- if eq "true" (include "common.ingress.supportsPathType" $) }}
             pathType: {{ default "ImplementationSpecific" .pathType }}
             {{- end }}
             backend: {{- include "common.ingress.backend" (dict "serviceName" (include "dashboard.serviceName" $) "servicePort" "dashboard-http" "context" $) | nindent 14 }}
-          - path: {{ default "/" .path }}api/v1
+          - path: ({{ default "/" .path }}api/v1.*)
+            {{- if eq "true" (include "common.ingress.supportsPathType" $) }}
+            pathType: {{ default "ImplementationSpecific" .pathType }}
+            {{- end }}
+            backend: {{- include "common.ingress.backend" (dict "serviceName" (include "backend.serviceName" .) "servicePort" "backend-http" "context" $)  | nindent 14 }}
+          - path: ({{ default "/" .path }}web.*)
             {{- if eq "true" (include "common.ingress.supportsPathType" $) }}
             pathType: {{ default "ImplementationSpecific" .pathType }}
             {{- end }}
-- 
GitLab