AlinsRan opened a new pull request, #13446:
URL: https://github.com/apache/apisix/pull/13446
## Summary
The `proxy-buffering` plugin controls nginx proxy buffering behavior per
route. When proxy buffering is disabled, nginx streams responses directly to
clients without buffering, which is essential for **Server-Sent Events (SSE)**,
streaming APIs, and real-time data delivery.
This plugin runs at a very high priority (21991) so it takes effect before
authentication plugins, ensuring the streaming behavior is established early in
the request lifecycle.
## Changes
- New plugin `apisix/plugins/proxy-buffering.lua` (priority: 21991)
- Extends `apisix/init.lua` with a `disable_proxy_buffering_access_phase()`
handler and routing check
- Extends `apisix/cli/ngx_tpl.lua` with a `@disable_proxy_buffering` nginx
location block (similar to `@grpc_pass`), wrapped in `{% if
enabled_plugins["proxy-buffering"] then %}`
- CLI test using `make init` + nginx.conf verification pattern
## Example
```shell
admin_key=$(yq '.deployment.admin.admin_key[0].key' conf/config.yaml | sed
's/"//g')
# Configure a route with proxy buffering disabled for SSE
curl http://127.0.0.1:9180/apisix/admin/routes/1 -X PUT -H "X-API-KEY:
${admin_key}" -d '{
"uri": "/events",
"plugins": {
"proxy-buffering": {
"disable_proxy_buffering": true
}
},
"upstream": { "type": "roundrobin", "nodes": { "127.0.0.1:1980": 1 } }
}'
```
Requests to `/events` will be proxied with `proxy_buffering off`, allowing
SSE or chunked streaming responses to be delivered immediately to the client.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]