@@ -103,6 +103,7 @@ func generateNginxCfg(p NginxCfgParams) (version1.IngressNginxConfig, Warnings)
103103 wsServices := getWebsocketServices (p .ingEx )
104104 spServices := getSessionPersistenceServices (p .BaseCfgParams .Context , p .ingEx )
105105 rewrites := getRewrites (p .BaseCfgParams .Context , p .ingEx )
106+ rewriteTarget , rewriteTargetWarnings := getRewriteTarget (p .BaseCfgParams .Context , p .ingEx )
106107 sslServices := getSSLServices (p .ingEx )
107108 grpcServices := getGrpcServices (p .ingEx )
108109
@@ -129,6 +130,7 @@ func generateNginxCfg(p NginxCfgParams) (version1.IngressNginxConfig, Warnings)
129130 }
130131
131132 allWarnings := newWarnings ()
133+ allWarnings .Add (rewriteTargetWarnings )
132134
133135 var servers []version1.Server
134136 var limitReqZones []version1.LimitReqZone
@@ -255,7 +257,7 @@ func generateNginxCfg(p NginxCfgParams) (version1.IngressNginxConfig, Warnings)
255257 ssl := isSSLEnabled (sslServices [path .Backend .Service .Name ], cfgParams , p .staticParams )
256258 proxySSLName := generateProxySSLName (path .Backend .Service .Name , p .ingEx .Ingress .Namespace )
257259 loc := createLocation (pathOrDefault (path .Path ), upstreams [upsName ], & cfgParams , wsServices [path .Backend .Service .Name ], rewrites [path .Backend .Service .Name ],
258- ssl , grpcServices [path .Backend .Service .Name ], proxySSLName , path .PathType , path .Backend .Service .Name )
260+ ssl , grpcServices [path .Backend .Service .Name ], proxySSLName , path .PathType , path .Backend .Service .Name , rewriteTarget , path . Path )
259261
260262 if p .isMinion && cfgParams .JWTKey != "" {
261263 jwtAuth , redirectLoc , warnings := generateJWTConfig (p .ingEx .Ingress , p .ingEx .SecretRefs , & cfgParams , getNameForRedirectLocation (p .ingEx .Ingress ))
@@ -320,7 +322,7 @@ func generateNginxCfg(p NginxCfgParams) (version1.IngressNginxConfig, Warnings)
320322 pathtype := networking .PathTypePrefix
321323
322324 loc := createLocation (pathOrDefault ("/" ), upstreams [upsName ], & cfgParams , wsServices [p .ingEx .Ingress .Spec .DefaultBackend .Service .Name ], rewrites [p .ingEx .Ingress .Spec .DefaultBackend .Service .Name ],
323- ssl , grpcServices [p .ingEx .Ingress .Spec .DefaultBackend .Service .Name ], proxySSLName , & pathtype , p .ingEx .Ingress .Spec .DefaultBackend .Service .Name )
325+ ssl , grpcServices [p .ingEx .Ingress .Spec .DefaultBackend .Service .Name ], proxySSLName , & pathtype , p .ingEx .Ingress .Spec .DefaultBackend .Service .Name , rewriteTarget , "/" )
324326 locations = append (locations , loc )
325327
326328 if cfgParams .HealthCheckEnabled {
@@ -487,9 +489,10 @@ func generateIngressPath(path string, pathType *networking.PathType) string {
487489 return path
488490}
489491
490- func createLocation (path string , upstream version1.Upstream , cfg * ConfigParams , websocket bool , rewrite string , ssl bool , grpc bool , proxySSLName string , pathType * networking.PathType , serviceName string ) version1.Location {
492+ func createLocation (path string , upstream version1.Upstream , cfg * ConfigParams , websocket bool , rewrite string , ssl bool , grpc bool , proxySSLName string , pathType * networking.PathType , serviceName string , rewriteTarget string , originalPath string ) version1.Location {
491493 loc := version1.Location {
492494 Path : generateIngressPath (path , pathType ),
495+ OriginalPath : originalPath ,
493496 Upstream : upstream ,
494497 ProxyConnectTimeout : cfg .ProxyConnectTimeout ,
495498 ProxyReadTimeout : cfg .ProxyReadTimeout ,
@@ -498,6 +501,7 @@ func createLocation(path string, upstream version1.Upstream, cfg *ConfigParams,
498501 ClientMaxBodySize : cfg .ClientMaxBodySize ,
499502 Websocket : websocket ,
500503 Rewrite : rewrite ,
504+ RewriteTarget : rewriteTarget ,
501505 SSL : ssl ,
502506 GRPC : grpc ,
503507 ProxyBuffering : cfg .ProxyBuffering ,
0 commit comments