AlinsRan opened a new pull request, #13348:
URL: https://github.com/apache/apisix/pull/13348

   ## 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`)
   
   ## 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]

Reply via email to