我需要使用很多规则的redirect地图(2k +行,文件大小是〜200K)
我在nginx中有以下设置:
map $uri $new_uri { include /etc/nginx/conf.d/redirects.map; } server { listen 80 default_server; listen [::]:80 default_server; # redirects if ($new_uri) { rewrite ^ $new_uri permanent; }
如此处所述,并在此处find。 问题:configtest失败:
nginx: [emerg] could not build map_hash, you should increase map_hash_bucket_size: 64
我试图将map_hash_max_size和map_hash_bucket_size增加到相当疯狂的值:
map $uri $new_uri { map_hash_max_size 262144; map_hash_bucket_size 262144; include /etc/nginx/conf.d/redirects.map; }
但仍然有相同的错误(以'64'结尾)。 我select了这些值,使它们大于文件大小。 我确定我通过添加“blabla”来编辑活动configuration,并看到“未知指令”
那么,应该如何设定这些价值呢? 不幸的是官方文档中没有太多细节。
map_hash_max_size和map_hash_bucket_size必须位于http上下文中,即map指令之外。
map_hash_max_size 262144; map_hash_bucket_size 262144; map $uri $new_uri { include /etc/nginx/conf.d/redirects.map; }