我想在nginx的http上下文中设置一个variables,所以它适用于我所有的服务器。 但是,只有服务器和位置支持“if”。
我怎样才能在http上下文中设置一个variables,这将影响所有的服务器?
可能lua模块能够帮助(虽然我宁愿有一个纯粹的nginx解决scheme)。 如果是这样,请举个例子。
我只是想设置下面的variables,所以它适用于所有的服务器:
# only allow gzip encoding. For all other cases, use identity (uncompressed) if ($http_accept_encoding ~* "gzip") { set $sanitised_accept_encoding "gzip"; } if ($http_accept_encoding != "gzip") { set $sanitised_accept_encoding ""; }
使用地图模块: http : //nginx.org/en/docs/http/ngx_http_map_module.html
map $http_accept_encoding $sanitised_accept_encoding { ~*gzip gzip; }