【问题标题】:Using nginx modules with chef nginx cookbook将 nginx 模块与 chef nginx 食谱一起使用
【发布时间】:2015-11-07 23:02:08
【问题描述】:

我正在尝试使用 chef 来配置一个带有 nginx 的 centos 网络服务器。我想使用 http_auth_request_module 和 headers_more_module。我的角色如下所示:

{
    "name" : "cms-aws",
    "description" : "a role to deploy cms to aws",
    "default_attributes" : {
        "nginx" : {
            "source" : {
                "modules" : ["nginx::http_auth_request_module","nginx::headers_more_module"]
            }
        }
    },
    "run_list" : [
        "runit",
        "python",
        "build-essential",
        "gunicorn",
        "nginx::source",
        "openssl",
        "yum",
        "git",
        "yum-epel",
        "my-custom-cookbook",
        "supervisor"
    ]
}

但是,当我在服务器上运行 nginx -V 时,这些模块没有列出,当我在我的 conf 文件中使用 auth_request 指令时,nginx 会抱怨。

我也尝试了以下属性,但是当我运行它时厨师找不到那些食谱:

"default_attributes" : {
    "nginx" : {
        "source" : {
            "modules" : ["http_auth_request_module","headers_more_module"]
        }
    }
},

编辑: 所以我已经确定我运行它的 AMI 已经安装了 nginx。因此,当 systemctl 启动 nginx 时,它会命中先前存在的,而不是厨师安装的那个。我尝试修改我的属性:

"default_attributes" : {
    "nginx" : {
        "source" : {
            "modules" : ["nginx::http_auth_request_module","nginx::headers_more_module"]
        },
        "binary" : "/usr/sbin/nginx"
    }
},

但是 chef 仍然在/opt/nginx-1.6.2/sbin/nginx 安装 nginx,知道如何纠正这个问题吗?

编辑编辑:原来 nginx 没有在这个 AMI 上开箱即用地安装,所以说明书将它安装在 /usr/sbin/nginx,但是当我运行 nginx -V 时,没有列出所需的模块。当我运行/opt/nginx-1.6.2/sbin/nginx -V 时,它会列出请求的模块。

【问题讨论】:

  • 在那个盒子上,当你运行 which -a nginx 时你会得到什么?基本上,nginx中安装/链接/找到了多少个地方?

标签: nginx centos chef-infra


【解决方案1】:

即使 nginx 是从一个包中安装的,nginx 食谱也会创建一个从 /opt/nginx-1.6.2/sbin/ 启动 nginx 的 runit 服务。你可以用runit的sv command管理它

sudo sv status nginx
sudo sv up nginx

在 chef 中从源代码编译 nginx 时,强制删除同一配方中的任何现有包是有意义的:

package("nginx") { action :remove }

由于您的 nginx 似乎编译正确(/opt/nginx-1.6.2/sbin/nginx -V 产生正确的结果),以上应该足以解决问题。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-11-06
    • 1970-01-01
    • 2023-04-05
    • 2019-01-06
    相关资源
    最近更新 更多