diff --git a/internal/mode/static/nginx/config/servers.go b/internal/mode/static/nginx/config/servers.go index 2e9728620d..0affb0635f 100644 --- a/internal/mode/static/nginx/config/servers.go +++ b/internal/mode/static/nginx/config/servers.go @@ -244,9 +244,12 @@ func updateLocationsForFilters( return buildLocations } - if filters.RequestMirror != nil { + filtersRequestMirror := filters.RequestMirror + if filtersRequestMirror != nil { for i := range buildLocations { - buildLocations[i].MirrorPath = *filters.RequestMirror.Target + if filtersRequestMirror.Target != nil { + buildLocations[i].MirrorPath = *filtersRequestMirror.Target + } } } diff --git a/internal/mode/static/nginx/config/servers_test.go b/internal/mode/static/nginx/config/servers_test.go index 05253b79ee..cdff6985da 100644 --- a/internal/mode/static/nginx/config/servers_test.go +++ b/internal/mode/static/nginx/config/servers_test.go @@ -888,7 +888,6 @@ func TestCreateServerWithMirrors(t *testing.T) { }, }, }, - // addition { Path: "/mirroring", PathType: dataplane.PathTypePrefix, @@ -898,7 +897,7 @@ func TestCreateServerWithMirrors(t *testing.T) { RequestMirror: &dataplane.HTTPRequestMirrorFilter{ Namespace: helpers.GetPointer("cafe.example.com"), Port: helpers.GetPointer(int32(8080)), - Scheme: helpers.GetPointer("http"), + Target: helpers.GetPointer("/cafe.example.com-mirroring-mirror"), }, }, BackendGroup: fooGroup, @@ -953,11 +952,13 @@ func TestCreateServerWithMirrors(t *testing.T) { Path: "/mirroring/", ProxySetHeaders: defaultSetHeader, ProxyPass: "http://$test__route1_rule0$request_uri", + MirrorPath: "/cafe.example.com-mirroring-mirror", }, { Path: "= /mirroring", ProxySetHeaders: defaultSetHeader, ProxyPass: "http://$test__route1_rule0$request_uri", + MirrorPath: "/cafe.example.com-mirroring-mirror", }, { Path: "/mirroring_mirror/",