浏览 4.2k
NGINX中的某些指令正在使用ngx_http_compile_complex_value(&ccv)来编译变量,并使用ngx_http_complex_value()来在运行时获取指令参数的原始值。 同样,其他一些指令也使用ngx_http_script_compile(&sc)和ngx_http_script_run()实现相同的目标。
请问这两者之间的区别是什么?

按点赞数排序
按时间排序
自问自答了。看了一下代码,感觉ngx_http_compile_complex_value和ngx_http_script_compile是两套实现,前者对后者进行了封装,使用起来应该更方便。
比如,如果有一个指令需要支持复杂变量,使用ngx_http_compile_complex_value只需要定义一个ngx_http_complex_value_t变量就可以。但是使用ngx_http_script_compile需要定义flushes,lengths,variables一系列数组。。
1
回答于2021-04-01 21:32
用body_filter_by_lua指令实现成本较小,参见https://github.com/openresty/lua-nginx-module#body_filter_by_lua,注意这会降低Nginx的转发性能,如果能在上游应用服务器上做更好
微信公众号
加入微信群