Salt:增加 nginx server_names_hash_bucket_size

问题:

你使用 saltstack 自动部署配置到你的服务器。使用默认配置安装 nginx 后,你需要增加 server_names_hash_bucket_size,否则它不会启动。

解决方案

最明显的解决方案是用你制作的配置替换整个配置文件。然而,这在 nginx 版本兼容性方面可能有一些缺点,因此替换单个变量可能有用。

为此,使用这样的 SLS 指令:

increase_server_names_hash_bucket_size.sh
sed -i 's/# server_names_hash_bucket_size 64;/server_names_hash_bucket_size 96;/g' /etc/nginx/nginx.conf

此命令在 nginx 包安装后运行,将 Debian 默认值替换为 96。已修改的值不被替换。根据使用的确切系统/发行版,你可能需要使用正则表达式或其他默认值。


Check out similar posts by category: Linux, Nginx