Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/loops/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Loops 如何从httpd.conf apache导出ssl密钥、crt和CA以将其用于所有用户的nginx_Loops_Ssh_Grep_Find_Xargs - Fatal编程技术网

Loops 如何从httpd.conf apache导出ssl密钥、crt和CA以将其用于所有用户的nginx

Loops 如何从httpd.conf apache导出ssl密钥、crt和CA以将其用于所有用户的nginx,loops,ssh,grep,find,xargs,Loops,Ssh,Grep,Find,Xargs,使用自定义设置,将nginx用作cpanel的web引擎 需要命令导出ssl文件以将其用于nginx cpanel现在使用由Comodo提供动力的AutoSL,免费提供,并在任何用户域ssl过期时自动续订 示例httpd.conf <VirtualHost 4xx30:4433> ServerName xnxxsch.com <IfModule ssl_module> SSLCertificateFile /var/cpanel/ssl/installed/ce

使用自定义设置,将nginx用作cpanel的web引擎 需要命令导出ssl文件以将其用于nginx

cpanel现在使用由Comodo提供动力的AutoSL,免费提供,并在任何用户域ssl过期时自动续订

示例httpd.conf

<VirtualHost 4xx30:4433>
  ServerName xnxxsch.com
  <IfModule ssl_module>
 SSLCertificateFile /var/cpanel/ssl/installed/certs/xnh_com_d98c5_67ca3_150707$
    SSLCertificateKeyFile /var/cpanel/ssl/installed/keys/d98c5_67ca3_76c14a301e0260891bbe91504$
    SSLCACertificateFile /var/cpanel/ssl/installed/cabundles/cPanel_Inc__681917bfb43af6b642178$
  </IfModule>
</VirtualHost>

<VirtualHost 46.xx30:4433>
  ServerName xxxh.com
  <IfModule ssl_module>
 SSLCertificateFile /var/cpanel/ssl/installed/certs/xnah_com_d98c5_67ca3_150707$
    SSLCertificateKeyFile /var/cpanel/ssl/installed/keys/d98c5_67ca3_76c14a301e0260891bbe91504$
    SSLCACertificateFile /var/cpanel/ssl/installed/cabundles/cPanel_Inc__681917bfb43af6b642178$
  </IfModule>
</VirtualHost>
我导出所有需要使用的at循环

获取其下的SSLCertificateKeyFile


并将其名为servername.crt复制到/etc/nginx/ssl/

我相信一些效率狂热者会因此窒息,但它应该可以工作:

#!/bin/bash
# Look for ServerName, and extract the value.  Loop over results.
for server in $( grep ServerName httpd.conf | sed 's/.*ServerName\s*//' ); do
    echo $server
    # Pull out the block of XML for that server
    block=$( grep -A5 "$server" httpd.conf)

    # Extract file names from the XML block
    SSLCertificateFile=$( echo "$block" | sed -n 's/.*SSLCertificateFile\s*//p')
    SSLCertificateKeyFile=$( echo "$block" | sed -n 's/.*SSLCertificateKeyFile\s*//p')
    SSLCACertificateFile=$( echo "$block" | sed -n 's/.*SSLCACertificateFile\s*//p')

    # Create files
    cp "$SSLCertificateKeyFile" "${server}.key"
    cat "$SSLCertificateFile" "$SSLCACertificateFile" > "${server}.crt"
done
# end of loop

如何,我需要编程脚本帮助nginx使用CPANELD的ssl您是否希望SSLCertificateFile和SSLCertificateFile一起包含在一个文件中?是的,请使用cat SSLCertificateFile SSLCertificateFile>>new.crtif设置,如果[-n“$SSLCertificateKeyFile”];然后在创建文件之前,因为并非所有服务器名都有文件我设置了cat名称为1s的文件只有空enter,因为代码必须处于其他状态如果服务器名有破折号(domain us.com)他的文件未被选中,则只剩下一个问题我只是将xnxxsch.com更改为xnxx-sch.com,它仍然工作正常。我可以把我的文件httpd.conf发送给您测试它吗?
#!/bin/bash
# Look for ServerName, and extract the value.  Loop over results.
for server in $( grep ServerName httpd.conf | sed 's/.*ServerName\s*//' ); do
    echo $server
    # Pull out the block of XML for that server
    block=$( grep -A5 "$server" httpd.conf)

    # Extract file names from the XML block
    SSLCertificateFile=$( echo "$block" | sed -n 's/.*SSLCertificateFile\s*//p')
    SSLCertificateKeyFile=$( echo "$block" | sed -n 's/.*SSLCertificateKeyFile\s*//p')
    SSLCACertificateFile=$( echo "$block" | sed -n 's/.*SSLCACertificateFile\s*//p')

    # Create files
    cp "$SSLCertificateKeyFile" "${server}.key"
    cat "$SSLCertificateFile" "$SSLCACertificateFile" > "${server}.crt"
done
# end of loop