在 Chef-server 上禁用 ssl?

Disable ssl on Chef-server?

我在 /etc/opscode/chef-server.rb 文件和 运行 chef-server-ctl reconfigure 中设置了 nginx['enable_non_ssl']=true 但是当我尝试为 chef 卷曲 http 端口时我仍然得到重定向 which kind的失败此设置的目的。请参阅下面的错误。

我的 chef-server.rb 文件:

cat /etc/opscode/chef-server.rb

nginx['enable_non_ssl']=true
nginx['non_ssl_port']=80

运行 重新配置:

chef-server-ctl reconfigure

Starting Chef Client, version 12.0.3
resolving cookbooks for run list: ["private-chef::default"]
[2015-05-25T13:12:26+00:00] WARN: Cookbook 'local-mode-cache' is empty or entirely chefignored at /opt/opscode/embedded/cookbooks/local-mode-cache
[2015-05-25T13:12:26+00:00] WARN: Cookbook 'local-mode-cache' is empty or entirely chefignored at /opt/opscode/embedded/cookbooks/local-mode-cache
[2015-05-25T13:12:26+00:00] WARN: Cookbook 'local-mode-cache' is empty or entirely chefignored at /opt/opscode/embedded/cookbooks/local-mode-cache
....

显示我仍然被重定向的 Curl 命令:

curl http://chef-xxx.xxxxxx.com

<html>
<head><title>301 Moved Permanently</title></head>
<body bgcolor="white">
<center><h1>301 Moved Permanently</h1></center>
<hr><center>openresty/1.7.10.1</center>
</body>
</html>

我如何启动一个工作的主厨服务器?

Relevant settings from Chef:

Note The chef-server.rb file does not exist by default. To modify the settings for the Chef server, create a file named chef-server.rb in the /etc/opscode/ directory.

Note This file was named private-chef.rb in previous versions of Enterprise Chef. After an upgrade to Chef server 12 from Enterprise Chef, the private-chef.rb file is symlinked to chef-server.rb. The private-chef.rb file is deprecated, starting with Chef server 12.

nginx['enable_non_ssl']

Use to allow port 80 redirects to port 443. When this value is set to false, load balancers on the front-end hardware are allowed to do SSL termination of the WebUI and API. Default value: false.

nginx['non_ssl_port']   

The port on which the WebUI and API are bound for non-SSL connections. Default value: 80. Use nginx['enable_non_ssl'] to enable or disable SSL redirects on this port number. Set to false to disable non-SSL connections.

所以根据以上我相信你需要edit/create/etc/opscode/目录下的chef-server.rb文件,然后运行chef-server-ctl reconfigure.

chef-server.rb 文件中的更改使 url 成为 http 但当我登录时再次提示 https 登录方式;用户登录两次,一次在 http 中,一次在 https 中。

让我知道您是否有机会尝试此操作以及配置是否成功作为 HTTP 实例提前致谢。

所以,我调查了这个问题并发现了下一个:

除了 Nginx,WebUI chef-manage 使用 Unicorn web-server 并且应用程序有 属性 config.force_ssl=true 除非 ENV['NO_SSL']。

因此,要禁用 SSL,您需要将环境变量 export NO_SSL=true 传递给 WebUI 的 运行 命令或 运行-脚本。

我遇到了同样的问题并已修复

最近安装的 Chef Server (chef-manage v2.4.4)

我遇到了同样的问题

You can see your Chef Manage version by reading the change log of your deployed chef server: http(s)://your-chef-server.com/changelog

我们想要什么

在专用服务器上安装我的 Chef 服务器实例后,它确实可以使用 SSL 正常工作。

但我们的生产服务器部署在私有 VLAN 中的专用主机上,用户通过 nginx 网络服务器 运行 作为反向代理访问服务或网络应用程序。

因此,为了将 Chef 服务器置于生产模式,我必须配置我的反向代理来代理请求:

这里是正确的 request/response 路由模式:

要求:

client    443 >> 443 chef.company.com (DNS: rev-proxy)
rev-proxy  80 >> 80  chef.vlan

回复:

rev-proxy  80 << 80  chef.vlan
client    443 << 443 chef.company.com

正常发行

但是,像您一样,Chef 服务器默认配置强制 SSL 从反向代理重定向到 vlan 中的 Chef 主机。 它会导致无限重定向循环:

client     443 >> 443 rev-proxy
proxy       80 >> 80  chef.vlan
client      80 << 80  chef.company.com (redirect to https://$host$request_uri)
client     443 >> 443 rev-proxy
proxy       80 >> 80  chef.vlan
client      80 << 80  chef.company.com (redirect to https://$host$request_uri)
...
client     443 >> 443 rev-proxy
proxy       80 >> 80  chef.vlan
client      80 << 80  chef.company.com (redirect to https://$host$request_uri)
...

正常修复

所以我们必须禁用 SSL chef.vlan 端。

普通方法是编辑文件/opt/obscode.chef-server.rb(如果不存在则创建),方法是插入以下指令:

nginx['enable_non_ssl']=true

和可选的(因为这已经是默认值)以下一个:

nginx['non_ssl_port']=80

因此我们只需要重新配置主厨服务器:

# chef-server-ctl reconfigure

但是 chef-server 有一个 bug

但是用于生成 nginx conf 文件的 chef 模板配方中存在一个错误。因此,当我们重新配置厨师服务器时,先前的指令将被忽略。

所以无限循环停留在那里。

Bug Ticket: https://tickets.opscode.com/browse/CHEF-3999

此外,您还可以查看这些其他资源:

https://github.com/chef/omnibus-chef/pull/57

https://docs.chef.io/config_rb_server.html

https://github.com/chef/chef-server/issues/973

解决问题

要解决这种情况,我必须采用问题单中提出的解决方案。

在 Chef 主机上找到 nginx 配置文件

root@chef-srv:~# find / -name nginx.conf
/opt/chef-manage/embedded/service/gem/ruby/2.2.0/gems/unicorn-4.9.0/examples/nginx.conf
/opt/opscode/embedded/service/gem/ruby/2.2.0/gems/unicorn-5.1.0/examples/nginx.conf
/opt/opscode/embedded/conf/nginx.conf
/var/opt/opscode/nginx/etc/nginx.conf

最后一个是内嵌的nginx conf文件。它包含以下块代码,问题来源:

# We support three options: serve nothing on non_ssl_port (80),
# redirect to https, or actually serve the API.
      server {
        listen 80;
        access_log /var/log/opscode/nginx/rewrite-port-80.log;
        return 301 https://$host$request_uri;
      }

找到源嵌入式 nginx 配置的 nginx 配置配方

root@chef-srv:~# find / -name nginx.rb
/opt/chef-manage/embedded/cookbooks/omnibus-chef-manage/recipes/nginx.rb
/opt/chef-manage/embedded/cookbooks/cache/cookbooks/omnibus-chef-manage/recipes/nginx.rb
/opt/opscode/embedded/cookbooks/private-chef/recipes/nginx.rb
/var/opt/opscode/local-mode-cache/cookbooks/private-chef/recipes/nginx.rb

第三个是生成嵌入式nginx配置的模板:

/opt/opscode/embedded/cookbooks/private-chef/recipes/nginx.rb
  === > /var/opt/opscode/nginx/etc/nginx.conf

修复配方

我们必须添加以下几行来修复它:

node.default['private_chef']['nginx']['enable_non_ssl']=true

我们应该将其附加到以下块:

# Save node attributes back for use in config template generation
node.default['private_chef']['nginx']['ssl_certificate'] ||= ssl_crtfile
node.default['private_chef']['nginx']['ssl_certificate_key'] ||= ssl_keyfile
node.default['private_chef']['nginx']['ssl_dhparam'] ||= ssl_dhparam

所以最终的块代码如下所示:

# nano /opt/opscode/embedded/cookbooks/private-chef/recipes/nginx.rb

:

# Save node attributes back for use in config template generation
node.default['private_chef']['nginx']['ssl_certificate'] ||= ssl_crtfile
node.default['private_chef']['nginx']['ssl_certificate_key'] ||= ssl_keyfile
node.default['private_chef']['nginx']['ssl_dhparam'] ||= ssl_dhparam
node.default['private_chef']['nginx']['enable_non_ssl']=true

应用更改

最后,我们必须通过重新配置 Chef 服务器从菜谱模板重新生成 nginx 配置文件:

# chef-server-ctl reconfigure

然后路由模式按预期工作。

尽情享受吧!