Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RequestRedirect filter on HTTPRoute cannot preserve path in request #6557

Open
2 of 4 tasks
randmonkey opened this issue Oct 22, 2024 · 4 comments
Open
2 of 4 tasks
Labels
area/feature New feature or request area/gateway-api Relating to upstream Kubernetes SIG Networking Gateway API blocked
Milestone

Comments

@randmonkey
Copy link
Contributor

Is there an existing issue for this?

  • I have searched the existing issues

Does this enhancement require public documentation?

  • I have added an Acceptance Criteria item for adding and/or adjusting public documentation (if applicable)

Problem Statement

From FTI-6305.
Because the RequestRedirect filter is implemented by request-termination and response-transformer plugin. This cannot include variable part in the response head. So the redirect path in the response body is fixed and cannot preserve path in the request.

Proposed Solution

  • Use some other method to generate redirect response that can send variable response according to the request
    • For example: run a standalone server to send responses

Additional information

No response

Acceptance Criteria

  • Redirect path in the response header can be preserved if no path is given
  • ReplacePrefixMatch is also supported
@randmonkey randmonkey added area/feature New feature or request area/gateway-api Relating to upstream Kubernetes SIG Networking Gateway API labels Oct 22, 2024
@randmonkey randmonkey added this to the KIC v3.4.x milestone Nov 7, 2024
@mheap
Copy link
Member

mheap commented Nov 19, 2024

Can this be implemented with a pre-function plugin?

kong.response.exit(301, 'redirecting', {['Location'] = 'https://other.example.com/' .. kong.request.get_path_with_query()})

@programmer04
Copy link
Member

For redirect filter implementation in case of not using request-termination plugin please remember about extending

targets := lo.Values(targetMap)
// Warn if an upstream was created with 0 targets and no request-termination plugin is present.
// When the plugin is present there (may be a result of RequestRedirect filter) there may not be
// a target service (it may point to an arbitrary URL), hence do not log a warn.
if len(targets) == 0 && !lo.ContainsBy(service.Plugins, func(p kong.Plugin) bool {
return p.Name != nil && *p.Name == "request-termination"
}) {
t.logger.V(logging.InfoLevel).Info("No targets found to create upstream", "service_name", *service.Name)
}

@randmonkey
Copy link
Contributor Author

randmonkey commented Nov 22, 2024

@mheap has submitted a PR for adding a redirect plugin: Kong/kong#13900
Using the plugin (only for Kong 3.9, or other version that contains the plugin) should resolve this.
If Kong does not support this plugin, we should either:

  • Do not support it and report a translation error
  • Implement by pre-function plugin
    @mheap Which one do you think is the better resolution?

@mheap
Copy link
Member

mheap commented Nov 22, 2024

I think we should leave the existing implementation pre 3.9, and use the new plugin in 3.9+.

pre-function is used enough that I would not want to prevent users using it if adding redirects

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/feature New feature or request area/gateway-api Relating to upstream Kubernetes SIG Networking Gateway API blocked
Projects
None yet
Development

No branches or pull requests

3 participants