apache / apache/apisix-ingress-controller

feat: Support K8s Gateway API HttpRoute "Path redirects"

Open
#2,857 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Go
Stars
1.1k
Forks
390
Avg merge
3d 7h
Merged PRs (30d)
12

Description

### Description

As a user I want that APISIX Ingress-Controller supports the K8s Gateway API HttpRoute filter feature "Path redirects" (see https://gateway-api.sigs.k8s.io/guides/user-guides/http-redirect-rewrite/#path-redirects).

Currently a valid Gateway API definition like the following ends in a "Too many redirects" error in the browser.
```
apiVersion: gateway.networking.k8s.io/v1
kind: HTTPRoute
metadata:
name: my-redirect
spec:
parentRefs:
- namespace: apisix
name: apisix
rules:
- matches:
- path:
type: Exact
value: /my-path
filters:
- type: RequestRedirect
requestRedirect:
path:
type: ReplaceFullPath
replaceFullPath: /my-path/
statusCode: 307
```

The issue is, that function fillPluginFromHTTPRequestRedirectFilter currently does not inspect reqRedirect.Path and always uses the request's uri instead.

The implementation in APISIX Ingress-Controller should be possible with the param "regex_uri" of the ["redirect"-plugin](https://apisix.apache.org/docs/apisix/plugins/redirect/) and a implementation similar as for the HTTPRouteFilterURLRewrite.

Contributor guide

No contributing guide indexed for this repository

Research direction

Start with fillPluginFromHTTPRequestRedirectFilter and compare its handling with the implementation for HTTPRouteFilterURLRewrite. Review the Gateway API RequestRedirect path-redirect documentation and the APISIX redirect plugin's regex_uri parameter. Done means ReplaceFullPath in the example produces the requested path redirect with status code 307 rather than a redirect loop.

Written by the indexing model from the issue text.

Assessment

Tech stack
go, kubernetes
Domain
api, backend
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Active
Clarity
Clearly specified
Newbie friendliness
72/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.