【问题标题】:Creation of SSL .crt & .key files using Nginx Cookbook and placing it in Chef-Client使用 Nginx Cookbook 创建 SSL .crt 和 .key 文件并将其放置在 Chef-Client 中
【发布时间】:2014-12-17 22:53:27
【问题描述】:

在 nginx 食谱上创建 ssl 证书和密钥,并帮我把它放在下面提到的位置:

Nginx 中的属性attributes/default.rb

default['nginx']['ssl_certificate'] = '/etc/nginx/ssl/nginx.crt' default['nginx']['ssl_certificate_key']='/etc/nginx/ssl/nginx.key'

Nginx 中的配置templates/default/default.conf.erb

`服务器{ 听443;

 server_name  <%= node['nginx']['server_name'] %>;

 ssl <%= node['nginx']['ssl'] %>;
 ssl_certificate <%= node['nginx']['ssl_certificate'] %>;
 ssl_certificate_key <%= node['nginx']['ssl_certificate_key'] %>;

 #charset koi8-r;
 access_log  <%= node['nginx']['access_log'] %>;

 #error_page  404              /404.html;

 # redirect server error pages to the static page /50x.html

 error_page   500 502 503 504  /50x.html;
 location = /50x.html {
    root   <%= node['nginx']['root'] %>;
 }

 # Default application configuration

 location / {
    proxy_redirect    off;
    proxy_pass http://backend/lgweb1/;
    proxy_set_header Host               $host;
    proxy_set_header X-Real-IP          $remote_addr;
    proxy_set_header X-Forwarded-For    $proxy_add_x_forwarded_for;
    proxy_set_header   X-NginX-Proxy  true;
    proxy_cookie_domain localhost <%= node['nginx']['server_name'] %>;
    proxy_http_version 1.1;
 }
 location /media {
    if ($request_method != GET) {
        return 403;
    }
    set $args $args&user.name=ec2-user&op=OPEN;
    proxy_pass <server name>;

    }
} 
# Redirect all port 80 access to ssl.
server {
  listen 80;
  return 301 https://$host$request_uri;
}`

现在我正在寻找一个简单的代码,它将在各自的位置安装 .crt 和 .key 文件。

附: Chef 市场上可用的食谱有太多配置,我不需要也不了解它们,因为我是 CHEF 和​​ Coding 本身的新手。

注意:我使用的是 AMI 系统

【问题讨论】:

    标签: nginx chef-infra cookbook


    【解决方案1】:

    您最好的选择是超市的certificate 食谱。它将期望一个包含证书和密钥的数据包,并将该证书和密钥放在指定的位置,同时对其设置正确的权限。菜谱上的文档非常好,新手应该也能用得上。

    【讨论】:

    • 当然,我会试试的。 :)
    • 我在 Files 目录中手动创建了 nginx.crt 和 nginx.key,并使用了 recipes/default.rb 中的 Cookbook_File 将它们放置在各自的位置。成功了
    • 请注意,这将在您的食谱中以纯文本形式公开您的私钥(在源代码控制中以及在其他任何地方复制它 - 比如在您的节点上)。可能适合开发,但不是一个非常安全的生产计划。
    • 数据包是最安全的生产方式吗?
    • 我会说加密数据包是当今最常见的方法,但实际上并没有“好”的方法,只有很多“好的”方法。 Coderanger 有一篇很棒的博客文章 coderanger.net/chef-secrets。他确实是最好的 Chef 之一,即使他似乎对现有的解决方案也不满意。
    猜你喜欢
    • 1970-01-01
    • 2020-01-04
    • 2014-06-04
    • 2016-11-10
    • 1970-01-01
    • 1970-01-01
    • 2014-10-08
    • 2018-10-27
    • 1970-01-01
    相关资源
    最近更新 更多