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里面的部署按钮,否则会覆盖你刚编辑保存的配置文件。

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

  • 相关阅读:
    lubuntu18.04如何创建APPImage软件的桌面快捷方式
    查找一个程序所在的路径
    lubuntu18.04如何用命令行打开一个应用(application)
    linux shell(ubuntu18.04.4 LTS) autostart to change the wallpaper
    bash常用的快捷键
    mkfs格式化分区(为分区写入文件系统)
    fdisk交互
    Linux fdisk命令创建逻辑分区
    Linux fdisk命令创建扩展分区过程
    fdisk创立主分区过程
  • 原文地址:https://www.cnblogs.com/keleyu/p/15705886.html
Copyright © 2011-2022 走看看