我有两个安装在不同IP中的服务,一个是网站 www.test.org.bo (IP:172.16.0.11),另一个是在 cloud域下的NextCloud .test.org.bo (IP:172.16.0.13),都具有SSL证书。在使用SSL之前,该网站已通过网站的Apache配置中的虚拟主机(ProxyPass和ProxyPassReverse)在Internet和NextCloud上发布。两者均通过公共IP,端口80 HTTP指示,
<VirtualHost *:80>
ProxyPreserveHost On
ServerName cloud.test.org.bo
ProxyPass / http://172.16.0.13/
ProxyPassReverse / http://172.16.0.13/
</VirtualHost>
但是,既然每个站点都有一个证书,并且可以使用Apache的VirtualHost通过SSL通过端口443通过SSL进行访问,那么当您要访问时,您只能访问 https://www.test.org.bo https://cloud.test.org.bo ,将重定向到 https://www.test.org.bo 。在网站的Apache服务器中应用的配置如下:
在文件 /etc/apache2/sites-enabled/test.org.bo-ssl.conf
<IfModule mod_ssl.c>
<VirtualHost *:443>
ServerAdmin webmaster@test.org.bo
ServerName www.test.org.bo
DocumentRoot /var/www/testweb
ProxyRequests Off
ProxyPreserveHost Off
SSLEngine On
SSLProxyEngine On
SSLCertificateFile /etc/letsencrypt/live/test.org.bo/cert.pem
SSLCertificateKeyFile /etc/letsencrypt/live/test.org.bo/privkey.pem
ErrorLog ${APACHE_LOG_DIR}/www-ssl-error.log
CustomLog ${APACHE_LOG_DIR}/www-ssl-access.log combined
<FilesMatch "\.(cgi|shtml|phtml|php|py)$">
SSLOptions +StdEnvVars
</FilesMatch>
<Directory /usr/lib/cgi-bin>
SSLOptions +StdEnvVars
</Directory>
# ProxyPass / https://172.16.0.11/
# ProxyPassReverse / https://172.16.0.11/
</VirtualHost>
</IfModule>
此外,在文件 /etc/apache2/sites-enabled/cloud.test.org.bo-ssl.conf
中对NextCloud的配置<VirtualHost 172.16.0.13:443>
SSLEngine On
# SSLProxyEngine On
ServerName cloud.test.org.bo
# ProxyPreserveHost Off
ProxyRequests Off
ProxyPass / https://cloud.test.org.bo/
ProxyPassReverse / https://cloud.test.org.bo/
</VirtualHost>
请注意您的评论,在此先感谢您的帮助。