Tomcat 子域名 SSL

Tomcat 子域名 SSL

我使用 ProxyPass 和 ProxyPassReverse 指令将所有请求从 Tomcat 应用程序(从端口 8080)重定向到子域(端口 80)。此外,我在端口 80 上有默认的 php 网站。因此配置如下所示:

<VirtualHost xx.xx.xx.xx:80 >
    ServerName domain.com
    DocumentRoot /var/www/site
</VirtualHost>
<VirtualHost xx.xx.xx.xx:80 >
    ServerName sub.domain.com
    ProxyRequests Off
    ProxyPreserveHost On
    <Proxy *>
            Order deny,allow
            Allow from all
    </Proxy>
    ProxyPass / http://localhost:8080/
    ProxyPassReverse / http://localhost:8080/
</VirtualHost>

现在我必须添加 SSL 支持,因此我在配置中添加了以下几行:

NameVirtualHost *:443
<VirtualHost _default_:443>
    SSLEngine on
    SSLCertificateFile /usr/local/ssl/crt/public.crt
    SSLCertificateKeyFile /usr/local/ssl/private/private.key
    SSLCACertificateFile /usr/local/ssl/crt/intermediate.crt
    ServerName domain.com:443
    DocumentRoot /var/www/site
</VirtualHost>

但是问题是 https 仅在根站点上运行良好,但是当我尝试通过 https 获取子域时,它会将我重定向到不存在的页面...我该如何配置 apache 以实现这一点?

谢谢

答案1

您尚未为 sub.domain.com 添加 SSL(端口 443)虚拟主机,例如

<VirtualHost _default_:443>
ServerName sub.domain.com

SSLEngine On
SSLCertificateFile /usr/local/ssl/crt/public.crt
SSLCertificateKeyFile /usr/local/ssl/private/private.key
SSLCACertificateFile /usr/local/ssl/crt/intermediate.crt

ProxyRequests Off
ProxyPreserveHost On
<Proxy *>
        Order deny,allow
        Allow from all
</Proxy>

# Needed if you want to go to preserve the SSL connection all the way to tomcat,
# but not worth it as both daemons are on the same physical box.
#SSLProxyEngine On  

ProxyPass / http://localhost:8080/
ProxyPassReverse / http://localhost:8080/
</VirtualHost>   

相关内容