宝塔面板一个网站绑定两个域名配置SSL

宝塔面板一个网站绑定两个以上的域名配置SSL

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

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

3、开启a.com 的ssl

4、点击左侧配置文件

  1. <VirtualHost *:80>
  2. ServerAdmin webmaster@example.com
  3. DocumentRoot "/www/wwwroot/test.com/public"
  4. ServerName 7277db5a.test.com
  5. ServerAlias a.com b.com c.com
  6. #errorDocument 404 /404.html
  7. ErrorLog "/www/wwwlogs/test.com-error_log"
  8. CustomLog "/www/wwwlogs/test.com-access_log" combined
  9. #DENY FILES
  10. <Files ~ (\.user.ini|\.htaccess|\.git|\.svn|\.project|LICENSE|README.md)$>
  11. Order allow,deny
  12. Deny from all
  13. </Files>
  14. #PHP
  15. <FilesMatch \.php$>
  16. SetHandler "proxy:unix:/tmp/php-cgi-74.sock|fcgi://localhost"
  17. </FilesMatch>
  18. #PATH
  19. <Directory "/www/wwwroot/test.com/public">
  20. SetOutputFilter DEFLATE
  21. Options FollowSymLinks
  22. AllowOverride All
  23. Require all granted
  24. DirectoryIndex index.php index.html index.htm default.php default.html default.htm
  25. </Directory>
  26. </VirtualHost>
  27. <VirtualHost *:443>
  28. ServerAdmin webmasterexample.com
  29. DocumentRoot "/www/wwwroot/test.com/public"
  30. ServerName SSL.abc.com
  31. ServerAlias a.com
  32. #errorDocument 404 /404.html
  33. ErrorLog "/www/wwwlogs/test.com-error_log"
  34. CustomLog "/www/wwwlogs/test.com-access_log" combined
  35. #SSL
  36. SSLEngine On
  37. SSLCertificateFile /www/server/panel/vhost/cert/a.com/fullchain.pem
  38. SSLCertificateKeyFile /www/server/panel/vhost/cert/a.com/privkey.pem
  39. SSLCipherSuite EECDH+AESGCM:EDH+AESGCM:AES256+EECDH:AES256+EDH
  40. SSLProtocol All -SSLv2 -SSLv3 -TLSv1
  41. SSLHonorCipherOrder On
  42. #PHP
  43. <FilesMatch \.php$>
  44. SetHandler "proxy:unix:/tmp/php-cgi-74.sock|fcgi://localhost"
  45. </FilesMatch>
  46. #DENY FILES
  47. <Files ~ (\.user.ini|\.htaccess|\.git|\.svn|\.project|LICENSE|README.md)$>
  48. Order allow,deny
  49. Deny from all
  50. </Files>
  51. #PATH
  52. <Directory "/www/wwwroot/test.com/public">
  53. SetOutputFilter DEFLATE
  54. Options FollowSymLinks
  55. AllowOverride All
  56. Require all granted
  57. DirectoryIndex index.php index.html index.htm default.php default.html default.htm
  58. </Directory>
  59. </VirtualHost>

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

  1. <VirtualHost *:443>
  2. ...
  3. ServerAlias a.com
  4. ...
  5. SSLCertificateFile /www/server/panel/vhost/cert/a.com/fullchain.pem
  6. SSLCertificateKeyFile /www/server/panel/vhost/cert/a.com/privkey.pem
  7. ...
  8. </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里面的部署按钮,否则会覆盖你刚编辑保存的配置文件。

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

阅读剩余
THE END