我的虚拟主机在 Apache 2.4 中,用于 Apache 2.4 端口 80 上的常规网站
<VirtualHost *:80>
ProxyPreserveHost On
ProxyRequests Off
ServerName trident.openways.us
ServerAlias openways.us/Trident
ProxyPass / https://openways.us:8443/Trident
ProxyPassReverse / https://openways.us:8443/Trident
Redirect Permanent /Trident https://openways.us:8443/Trident
</VirtualHost>
将端口 80 上的调用重定向到 Tomcat SSL
<VirtualHost *:80>
ServerName trident.openways.us
ServerAlias openways.us/Trident
ProxyRequests on
ProxyPreserveHost On
<Proxy *>
Order deny,allow
Allow from all
</Proxy>
SSLProxyEngine on
ProxyPass /Trident https://openways.us:8443/Trident
ProxyPassReverse /Trident https://openways.us:8443/Trident
</VirtualHost>
我的 Tomcat server.xml
<Connector port="8080" protocol="HTTP/1.1"
connectionTimeout="20000"
redirectPort="8443" />
<Connector port="8443" scheme="https" secure="true" SSLEnabled="true"
SSLCertificateFile="C:\wamp\bin\apache\Apache2.4.4\conf\extra\openways.us_ssl_certificate.cer"
SSLCertificateKeyFile="C:\wamp\bin\apache\Apache2.4.4\conf\extra\_.openways.us_private_key.key"
SSLPassword="changeit"
SSLCertificateChainFile="C:\wamp\bin\apache\Apache2.4.4\conf\extra\-.openways.us_ssl_certificate_INTERMEDIATE.cer"
keyAlias="tomcat" SSLProtocol="TLSv1"/>
<!-- Define an AJP 1.3 Connector on port 8009 -->
<Connector port="8009" protocol="AJP/1.3" redirectPort="8443" />
尽管测试了不同的配置,但我在网上进行了调查,我无法让它们工作,除非重定向到
http://openways.us:8080/Trident,但没有 SSL
请帮助推荐正确的配置或调查地点
答案1
我终于在过去两天调查了许多来源,并找到了完美运行的配置,如下所示:
首先
在 httpd.conf 中
LoadModule proxy_module modules/mod_proxy.so
LoadModule proxy_ajp_module modules/mod_proxy_ajp.so
LoadModule proxy_balancer_module modules/mod_proxy_balancer.so
LoadModule proxy_connect_module modules/mod_proxy_connect.so
LoadModule proxy_ftp_module modules/mod_proxy_ftp.so
LoadModule proxy_http_module modules/mod_proxy_http.so
LoadModule proxy_scgi_module modules/mod_proxy_scgi.so
在 httpd-vhosts.conf 中
<VirtualHost *:80>
DocumentRoot "C:/wamp/www/openways/"
ServerName www.openways.us
ServerAlias openways.us
<Directory "c:/wamp/www/openways/">
</Directory>
Redirect Permanent / https://www.openways.us
</VirtualHost>
<VirtualHost *:80>
DocumentRoot "C:\Program Files\apache-tomcat-7.0.84\webapps"
ServerName openways.us
ServerAlias trident.openways.us
ProxyRequests Off
ProxyPass /Trident http://openways.us:8080/Trident/
<Location "/Trident">
Order allow,deny
Allow from all
</Location>
</VirtualHost>
<VirtualHost *:8443>
DocumentRoot "C:\Program Files\apache-tomcat-7.0.84\webapps"
ServerName openways.us
ServerAlias trident.openways.us
ProxyRequests Off
ProxyPass /Trident https://openways.us:8443/Trident/
<Location "/Trident">
Order allow,deny
Allow from all
</Location>
</VirtualHost>
在 httpd-ssl.conf 中
Listen 443
<VirtualHost *:443>
SSLEngine on
SSLCertificateFile
"C:\wamp\bin\apache\Apache2.4.4\conf\extra\openways.us_ssl_certificate.cer"
SSLCertificateKeyFile"C:\wamp\bin\apache\Apache2.4.4\conf\extra\_.openways.us_private_key.key"
ServerName openways.us
ServerAlias trident.openways.us
ProxyRequests Off
SSLProxyEngine on
SSLEngine On
SSLProxyVerify none
SSLProxyCheckPeerCN off
ProxyPass /Trident https://openways.us:8443/Trident/
<Location "/Trident">
Order allow,deny
Allow from all
</Location>
SSLCACertificateFile
"C:\wamp\bin\apache\Apache2.4.4\conf\extra\-.openways.us_ssl_certificate_INTERMEDIATE.cer"
</VirtualHost>
在 Tomcat server.xml 中
<Connector port="8080" protocol="HTTP/1.1"
connectionTimeout="20000"
redirectPort="8443" />
<Connector port="8443" scheme="https" secure="true" SSLEnabled="true"
SSLCertificateFile="C:\wamp\bin\apache\Apache2.4.4\conf\extra\openways.us_ssl_certificate.cer"
SSLCertificateKeyFile="C:\wamp\bin\apache\Apache2.4.4\conf\extra\_.openways.us_private_key.key"
SSLPassword="xxxxxxxx"
SSLCertificateChainFile="C:\wamp\bin\apache\Apache2.4.4\conf\extra\-.openways.us_ssl_certificate_INTERMEDIATE.cer"
keyAlias="tomcat" SSLProtocol="TLSv1"/>
<!-- Define an AJP 1.3 Connector on port 8009 -->
<Connector port="8009" protocol="AJP/1.3" redirectPort="8443" />
我真诚地希望这个解决方案能够帮助像我一样的人在配置 SSL 证书和 Apache / Tomcat 组合的初始步骤中
答案2
你有
ServerName www.openways.us/Trident
ServerAlias openways.us/Trident
这与任何主机都不匹配,因为主机不包含路径的任何部分。
首先删除它们:
ServerName www.openways.us
ServerAlias openways.us
然后,据说下层<VirtualHost *:80>
正在尝试使用 SSL 版本,但它只在与后面的 Tomcat 服务器的连接上使用 SSL。它根本没有向客户端实现 SSL,即
client <--HTTP(80)--> proxy <--HTTPS(8443)--> tomcat
虽然下面两种方法都可以:
client <--HTTPS(443)--> proxy <--HTTPS(8443)--> tomcat
client <--HTTPS(443)--> proxy <--HTTP(8080)--> tomcat
为此,你需要有一个HTTPS 虚拟主机, 反而。
答案3
您也可以使用 mod_jk(Apache Tomcat 连接器)执行相同操作。 https://tomcat.apache.org/connectors-doc/