zoukankan      html  css  js  c++  java
  • 同一个主机头的多域名绑定多个ssl证书的方法

    在我们开发系统的过程当中,可能会遇到这个实例情况,a.com,b.com,c.com同时指向同一个系统,但是如果我们以同一个主机头去设置a.com,b.com,c.com的时候,只能默认绑定一个域名的ssl证书,我们需求是在同一个主机头里同时绑定多个域名证书,类似这样的

    https://a.com
    https://b.com
    https://c.om

    铁牛以宝塔系统的方式来给大家做个实例,以下是操作步骤

    1、比如a.com b.com c.com 同时绑定一个网站

    2、申请证书,获取pem、key

    3、开启a.com 的ssl

    4、点击左侧配置文件

    <VirtualHost *:80>
        ServerAdmin webmaster@example.com
        DocumentRoot "/www/wwwroot/test.com/public"
        ServerName 7277db5a.test.com
        ServerAlias a.com b.com c.com
        #errorDocument 404 /404.html
        ErrorLog "/www/wwwlogs/test.com-error_log"
        CustomLog "/www/wwwlogs/test.com-access_log" combined
        
        #DENY FILES
         <Files ~ (\.user.ini|\.htaccess|\.git|\.svn|\.project|LICENSE|README.md)$>
           Order allow,deny
           Deny from all
        </Files>
        
        #PHP
        <FilesMatch \.php$>
                SetHandler "proxy:unix:/tmp/php-cgi-74.sock|fcgi://localhost"
        </FilesMatch>
        
        #PATH
        <Directory "/www/wwwroot/test.com/public">
            SetOutputFilter DEFLATE
            Options FollowSymLinks
            AllowOverride All
            Require all granted
            DirectoryIndex index.php index.html index.htm default.php default.html default.htm
        </Directory>
    </VirtualHost>
    <VirtualHost *:443>
        ServerAdmin webmasterexample.com
        DocumentRoot "/www/wwwroot/test.com/public"
        ServerName SSL.abc.com
        ServerAlias a.com 
        #errorDocument 404 /404.html
        ErrorLog "/www/wwwlogs/test.com-error_log"
        CustomLog "/www/wwwlogs/test.com-access_log" combined
        
        #SSL
        SSLEngine On
        SSLCertificateFile /www/server/panel/vhost/cert/a.com/fullchain.pem
        SSLCertificateKeyFile /www/server/panel/vhost/cert/a.com/privkey.pem
        SSLCipherSuite EECDH+AESGCM:EDH+AESGCM:AES256+EECDH:AES256+EDH
        SSLProtocol All -SSLv2 -SSLv3 -TLSv1
        SSLHonorCipherOrder On
        
        #PHP
        <FilesMatch \.php$>
                SetHandler "proxy:unix:/tmp/php-cgi-74.sock|fcgi://localhost"
        </FilesMatch>
        
     
        #DENY FILES
         <Files ~ (\.user.ini|\.htaccess|\.git|\.svn|\.project|LICENSE|README.md)$>
           Order allow,deny
           Deny from all
        </Files>
     
        #PATH
        <Directory "/www/wwwroot/test.com/public">
            SetOutputFilter DEFLATE
            Options FollowSymLinks
            AllowOverride All
            Require all granted
            DirectoryIndex index.php index.html index.htm default.php default.html default.htm
        </Directory>
    </VirtualHost>

    5、可以看到<VirtualHost *:443>标签内只配置了a.com的ssl证书。复制此标签内容,配置 b.com 和 c.com (其他部分省略) 需要改变的就三行

    <VirtualHost *:443>
       ...
        ServerAlias a.com 
       ...
        SSLCertificateFile /www/server/panel/vhost/cert/a.com/fullchain.pem
        SSLCertificateKeyFile /www/server/panel/vhost/cert/a.com/privkey.pem
          ...
    </VirtualHost>

    把B、C相应的证书放到 /www/server/panel/vhost/cert/*****.com/fullchain.pem 、 /www/server/panel/vhost/cert/*****.com/privkey.pem

    点击保存。

    注:配置好后就可以正常访问 htttps://a.com htttps://b.com htttps://c.com

    不要再点击ssl里面的部署按钮,否则会覆盖你刚编辑保存的配置文件。

    因此最好把配置文件的内容复制下来保存一份,防止以后误操作覆盖

  • 相关阅读:
    bzoj1178/luogu3626 会议中心 (倍增+STL::set)
    suoi31 最近公共祖先2 (倍增lca)
    luogu4155/bzoj4444 国旗计划 (倍增)
    [BZOJ1864][Zjoi2006]三色二叉树
    [Luogu3070][USACO13JAN]岛游记Island Travels
    [Luogu2458][SDOI2006]保安站岗
    [BZOJ1191][HNOI2006]超级英雄Hero
    [BZOJ1050][HAOI2006]旅行
    [Luogu2973][USACO10HOL]赶小猪Driving Out the Piggi…
    [BZOJ1833][ZJOI2010]数字计数
  • 原文地址:https://www.cnblogs.com/keleyu/p/15705886.html
Copyright © 2011-2022 走看看