feat: As a user, I want to use Nginx variables in proxy-rewrite.regex_uri
- Dominant language
- Lua
- Stars
- 17.1k
- Forks
- 2.9k
- Avg merge
- 3d 18h
- Merged PRs (30d)
- 62
Description
### Description
Currently, `proxy-rewrite` supports NGINX variable resolution in `uri` config parameter, **but not in `regex_uri`**. See [APISIX Docs | Plugins - proxy-rewrite](https://apisix.apache.org/docs/apisix/plugins/proxy-rewrite/#attributes) for reference.
Examples:
- 🟢 Nginx variable resolution in `uri`:
```yaml
proxy-rewrite:
uri: /api/$arg_name
```
- 🟢 Pattern variable resolution in `regex_uri`:
```yaml
proxy-rewrite:
regex_uri:
- ^/api/(.*)/users/(.*)$
- /v2/$1/external-users/$2
```
- 🔴 Nginx variable resolution in `regex_uri`:
```yaml
proxy-rewrite:
regex_uri:
- ^/api/(.*)/users/(.*)$
- /v2/$1/external-users/$arg_name
```
This is **not** allowed and will throw an error.
## Question
Since `regex_uri` already supports variables resolution for regex patterns (e.g. patterns matched by `(.*)/(.*)` can be referenced with `$1` and `$2`), I was wondering: why does `uri` allow Nginx variables resolution, but `regex_uri` does not? Is this a design choice? Are there any contraindications in implementing this feature?
Contributor guide
Research direction
Start with the proxy-rewrite plugin attributes in the linked APISIX documentation and trace the existing uri and regex_uri handling in the repository. Compare Nginx variable resolution with regex capture references such as $1 and $2; done means a supported regex_uri replacement can resolve an Nginx variable without breaking existing capture behavior, with coverage for the provided examples.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- lua, nginx
- Domain
- api, backend
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100