我有一个互联网可访问的Apache服务器,启用SSL和工作。 在本地networking上,有另一台服务器通过http提供一个tomcat应用程序。
Apache服务器反向代理tomcat应用程序。 当通过http使用apache服务器时,tomcat应用程序被正确代理,但是当通过https使用它时,tomcat服务器返回404找不到的资源。 那么https请求是否被转换为http? 我宁愿不触摸tomcatconfiguration,因为这不是我的区域。
这是我的configuration:
<VirtualHost *:443> ServerName ext-service.example.com SSLEngine on SSLCertificateFile /etc/apache2/ssl.crt/mycert.crt SSLCertificateKeyFile /etc/apache2/ssl.key/mykey.key SSLCertificateChainFile /etc/apache2/ssl.crt/mybundle.crt ProxyRequests Off ProxyPreserveHost Off <Proxy *> AddDefaultCharset off Order deny,allow Allow from all </Proxy> DocumentRoot /srv/www/empty/ ProxyPass / http://int-service.example.com/ ProxyPassReverse / http://int-service.example.com/ </VirtualHost>
如果tomcat设置为使用AJP,我build议你使用它。
ProxyPass / ajp://int-service.example.com:<ajp_port>/ ProxyPassReverse / ajp://int-service.example.com:<ajp_port>/
你将不得不适应tomcat的configuration,没有办法绕过它。 你的Apacheconfiguration看起来还好,只是两件事情,当我把它与我的设置进行比较时,
DocumentRoot在那里是没用的,你可以删除它,因为你代理的一切。 ProxyPreserveHost应该On 另一方面,Tomcat必须被告知前面有一个代理,它使用https而不是http。
应该有一个指定连接器的configuration文件。
<Connector port="80" <!-- add these lines --> scheme="https" proxyName="ext-service.example.com" proxyPort="443" <!-- other options --> />
在添加这些行之后,Tomcat知道应该如何生成URL。