我试图有条件地设置client_max_body_size 。 我已经按照在Nginx的答案中提出的configuration有条件地设置了一个variables ,但是这对我不起作用。
以下configuration文件足以重现:
daemon off; worker_processes 1; error_log /dev/stderr debug; events { worker_connections 1024; } http { access_log /dev/stdout; server { listen 80; location /test { set $cmbs 1m; if ($arg_long) { set $cmbs 5m; } client_max_body_size $cmbs; echo $cmbs; } } }
当我尝试用这个configuration启动Nginx时,它停止并投诉
nginx:[emerg]“client_max_body_size”指令无效值在/opt/nginx/nginx.conf:16
如果我删除了违规指令,Nginx就会启动,并以我期望的方式回显设置值。
我正在运行openresty / 1.7.10.1。 我也尝试了nginx / 1.9.4上面的小configuration。
从1.9.4版本开始,Nginx不支持variablesclient_max_body_size。