![虚拟主机 SSL 和非 SSL 与代理](https://linux22.com/image/791281/%E8%99%9A%E6%8B%9F%E4%B8%BB%E6%9C%BA%20SSL%20%E5%92%8C%E9%9D%9E%20SSL%20%E4%B8%8E%E4%BB%A3%E7%90%86.png)
我在 Apache 中有 1 个非 SSL 服务器和许多带代理的 SSL 服务器。
配置SSL服务器:
<VirtualHost *:443>
ServerName test.com
ServerAdmin [email protected]
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
SSLEngine on
SSLCertificateFile /etc/...
SSLCertificateKeyFile /etc/...
SSLCertificateChainFile /etc/...
ProxyRequests off
SSLProxyEngine on
ProxyPass / https://localhost:10000/
ProxyPassReverse / https://localhost:10000/
</VirtualHost>
<VirtualHost *:80>
ServerName test.com
ServerAdmin [email protected]
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
RewriteEngine On
RewriteCond %{SERVER_PORT} ^80$
RewriteRule ^(.*)$ https://%{SERVER_NAME}$1 [R=301,L]
</VirtualHost>
配置非SSL服务器:
<VirtualHost *:80>
ServerName test.test.com
ServerAdmin [email protected]
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
ProxyRequests off
ProxyPass / http://localhost:8101/
ProxyPassReverse / http://localhost:8101/
</VirtualHost>
当我关注 SSL 服务器时 - 一切正常。当我关注非 SSL 服务器时,Chrome 会向我显示 SSL 服务器。
这会是什么问题呢?
答案1
据我了解,您的评论(可以添加到主要问题中)的预期行为是:当您点击https://test.test.com=> 重定向至http://test.test.com不要停留在 test.com 上。看起来 test.com 是默认的,当你点击“https://”方案时,这应该是正常的:443 vhost。如果这个假设是正确的,那么你应该在 https 中告诉(:443) 部分:“嘿,回到 http://”就像这样
RewriteEngine On
RewriteCond %{HTTP_HOST} ^test\.test\.com [NC]
RewriteRule ^(.*)$ http://test.test.com/$1 [R=301,L]