我被要求在Debian Wheezy上将运行Apache和Tomcat-6的服务器从HTTP升级到HTTPS。 我已经成功地在Apache部分获得并安装了SSL证书,并检查了它们的工作原理(使用了两个不同的SSL检查器)。
接下来,我将下面的块添加到/etc/apache2/sites-available/default-ssl :
<VirtualHost *:80> ServerName server.name Redirect permanent / https://server.name/ </VirtualHost>
并将其放在同一个文件中的<VirtualHost _default_:443>块的末尾:
ProxyRequests Off ProxyPreserveHost On ProxyPass / http://localhost:8080/ ProxyPassReverse / http://localhost:8080/
在Tomcat方面,/ /etc/tomcat6/server.xml文件包含两个活动连接器:
<Connector port="8080" protocol="HTTP/1.1" connectionTimeout="20000" URIEncoding="UTF-8" redirectPort="8443" /> <Connector address="127.0.0.1" port="8009" protocol="AJP/1.3" redirectPort="8443" />
现在,当我去https://server.name/app/main/login.jspx ,我得到一个SSL连接,但login后消失。
如果我去https://server.name/app ,我立即redirect到http://server.name/app/main/login.jspx (没有SSL)。
(如果我只是去https://server.name/ ,我最终在/var/lib/tomcat6/webapps/ROOT/index.html定义的redirect页面。)
我究竟做错了什么? 我是否需要使用AJP代理?
如果在代理configuration中使用此连接器,请configurationproxyName , proxyPort 。
<Connector port="8080" protocol="HTTP/1.1" connectionTimeout="20000" URIEncoding="UTF-8" redirectPort="8443" scheme="https" proxyName="server.name" proxyPort="443" secure="true" />
您还需要将scheme和secure属性分别设置为https代理和https代理的值。
要在http服务器中将httpredirect到https,请尝试在默认configuration/etc/apache2/sites-available/000-default.conf添加指令。