diff --git a/pkg/controller/appdefinition/router.go b/pkg/controller/appdefinition/router.go index 7b03e76bc..f81313be8 100644 --- a/pkg/controller/appdefinition/router.go +++ b/pkg/controller/appdefinition/router.go @@ -184,7 +184,8 @@ func toNginxConf(routerName string, router v1.Router) (string, string) { buf.WriteString(route.TargetServiceName) buf.WriteString(":") buf.WriteString(strconv.Itoa(port)) - buf.WriteString(";\n}\n") + buf.WriteString(";\n proxy_set_header X-Forwarded-Host $http_host;") + buf.WriteString("\n}\n") if route.PathType == v1.PathTypePrefix && !strings.HasSuffix(route.Path, "/") { buf.WriteString("location ") buf.WriteString(route.Path) @@ -194,7 +195,8 @@ func toNginxConf(routerName string, router v1.Router) (string, string) { buf.WriteString(route.TargetServiceName) buf.WriteString(":") buf.WriteString(strconv.Itoa(port)) - buf.WriteString(";\n}\n") + buf.WriteString(";\n proxy_set_header X-Forwarded-Host $http_host;") + buf.WriteString("\n}\n") } if route.PathType == v1.PathTypePrefix && route.Path == "/" { buf.WriteString("location ") @@ -204,7 +206,8 @@ func toNginxConf(routerName string, router v1.Router) (string, string) { buf.WriteString(route.TargetServiceName) buf.WriteString(":") buf.WriteString(strconv.Itoa(port)) - buf.WriteString(";\n}\n") + buf.WriteString(";\n proxy_set_header X-Forwarded-Host $http_host;") + buf.WriteString("\n}\n") } } buf.WriteString("}\n") diff --git a/pkg/controller/appdefinition/testdata/router/expected.golden b/pkg/controller/appdefinition/testdata/router/expected.golden index 9c375e1c4..9db7a3406 100644 --- a/pkg/controller/appdefinition/testdata/router/expected.golden +++ b/pkg/controller/appdefinition/testdata/router/expected.golden @@ -66,7 +66,7 @@ spec: operator: Exists volumes: - configMap: - name: router-name-5f5b2f6b + name: router-name-e9cec3df name: conf status: {} @@ -78,18 +78,21 @@ data: listen 8080; location = /foo { proxy_pass http://foo-target:80; + proxy_set_header X-Forwarded-Host $http_host; } location = /zzzz { proxy_pass http://zzz-target:80; + proxy_set_header X-Forwarded-Host $http_host; } location /zzzz/ { proxy_pass http://zzz-target:80; + proxy_set_header X-Forwarded-Host $http_host; } } kind: ConfigMap metadata: creationTimestamp: null - name: router-name-5f5b2f6b + name: router-name-e9cec3df namespace: app-created-namespace ---