Apache-2.2

Tomcat 子域 SSL

  • January 18, 2013

我正在使用 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 以實現這一點?

謝謝

您尚未為 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>   

引用自:https://serverfault.com/questions/469910