control proxy_buffering with variables

Maxim Dounin mdounin at mdounin.ru
Fri Nov 17 20:30:27 UTC 2023


Hello!

On Fri, Nov 17, 2023 at 03:57:23AM +0000, public1020 via nginx wrote:

> I'm trying to control buffering with variables, but nginx complains about it,
> 
> nginx: [emerg] invalid value "$val" in "proxy_request_buffering" directive, it must be "on" or "off" in /etc/nginx/sites-enabled/test.conf:9
> 
> Is there any way to resolve this? Attached the configuration in question.

Much like most of the nginx configuration directives, 
"proxy_request_buffering" does not support variables.  Note that 
if variables are supported by a particular directive, this is 
explicitly documented in the directive description at nginx.org.

If you want to use different buffering options for different 
requests, consider using distinct locations instead.  Something 
like

    location / {
        proxy_pass http://127.0.0.1:3333;
    }

    location ~* enable {
        proxy_pass http://127.0.0.1:3333;
        proxy_request_buffering off;
        proxy_buffering off;
    }

would be close to the configuration you've tried to use, and 
mostly arbitrary conditions, including the exact equivalent to 
your configuration, can be implemented using internal 
redirections, such as with "rewrite".

Note well that the proxy_buffering can also be controlled from the 
backend via the X-Accel-Buffering response header.

-- 
Maxim Dounin
http://mdounin.ru/


More information about the nginx mailing list