From a0f8050b5a9af86d8af9956917c8507ac427c1b6 Mon Sep 17 00:00:00 2001 From: linweizhe Date: Tue, 9 Apr 2024 02:30:44 +0800 Subject: [PATCH] update condition and replacement --- nginx.tmpl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/nginx.tmpl b/nginx.tmpl index ff04268..3204754 100644 --- a/nginx.tmpl +++ b/nginx.tmpl @@ -276,8 +276,8 @@ grpc_pass {{ trim $proto }}://{{ trim $upstream }}; {{- else }} proxy_pass {{ trim $proto }}://{{ trim $upstream }}{{ trim $dest }}; - {{- if not (eq .Path "/") }} - proxy_redirect ~^/(.*)$ {{ trimSuffix `/` .Path }}/$1; + {{- if (hasPrefix "/" $dest) }} + proxy_redirect ~^{{ $dest }}(.*)$ {{ .Path }}$1; {{- end }} set $upstream_keepalive {{ if ne $keepalive "disabled" }}true{{ else }}false{{ end }}; {{- end }}