2016-02-10 25 views
0

因此,我有一个运行在端口8080上的tomcat服务器和一个运行在端口80和443上的Apache服务器。我可以通过使用这些虚拟服务器将整个网站重定向到https主机:使用ProxyPass将HTTP页面重定向到HTTPS到Tomcat服务器

<VirtualHost *:80> 
    Redirect permanent/https://localhost 
</VirtualHost> 

<VirtualHost _default_:443> 
    SSLEngine on 
    SSLCertificateFile /etc/httpd/crt/localhost.crt 
    SSLCertificateKeyFile /etc/httpd/crt/localhost.key 
    ProxyRequests off 
    ProxyPreserveHost on 
    ProxyPass/http://localhost:8080/ 
    ProxyPassReverse/http://localhost:8080/ 
    ProxyPass /catdapp http://localhost:8080/ 
    ProxyPassReverse /catdapp http://localhost:8080/ 
</VirtualHost> 

但是,想获得它,使它只重定向到HTTPS时,网址为localhost/#/loginlocalhost/catdapp/#/login

我曾尝试以下:

<VirtualHost *:80> 
    Redirect permanent /#/login https://localhost/#/login 
    Redirect permanent /catdapp/#/login https://localhost/#/login 
    ProxyRequests off 
    ProxyPreserveHost on 
    ProxyPass /#/login ! 
    ProxyPass /catdapp/#/login ! 
    ProxyPass/http://localhost:8080/ 
    ProxyPassReverse/http://localhost:8080/ 
    ProxyPass /catdapp http://localhost:8080/ 
    ProxyPassReverse /catdapp http://localhost:8080/ 
</VirtualHost> 

其中没有工作,在控制台显示它检索http://localhost/catdapp/partials/login.html所以我试图将其更改为这样:

<VirtualHost *:80> 
    Redirect permanent /catdapp/partials/login.html https://localhost/catdapp/partials/login.html 
    ProxyRequests off 
    ProxyPreserveHost on 
    ProxyPass /catdapp/partials/login.html ! 
    ProxyPass/http://localhost:8080/ 
    ProxyPassReverse/http://localhost:8080/ 
    ProxyPass /catdapp http://localhost:8080/ 
    ProxyPassReverse /catdapp http://localhost:8080/ 
</VirtualHost> 

,然后导致Firefox的控制台输出两个错误:

GET http://localhost/catdapp/partials/login.html 301 Moved Permanently 
GET https://localhost/catdapp/partials/login.html 200 OK 

的Apache访问日志显示:

"GET /catdapp/partials/login.html HTTP/1.1" 301 328 "http://localhost" "Mozilla/5.0 (X11; Linux x84_64; rv:38.0) Gecko/20100101 Firefox/38.0" 
"GET /catdapp/partials/login.html HTTP/1.1" 200 2054 "http://localhost" "Mozilla/5.0 (X11; Linux x84_64; rv:38.0) Gecko/20100101 Firefox/38.0" 

任何想法?

回答

0

#在客户端处理,在浏览器中 - 我没有看到它传输到服务器。

我不再担心混合模式操作,只是无条件地将所有内容重定向到https并继续:http/https混合模式下,您只会打开如此多的意外安全漏洞,会话泄漏或其他(现今)只是不值得麻烦。在https虚拟主机上添加一个HSTS header,在偶然使用错误协议(一旦客户端已经看到HSTS头,这应该是常态)的情况下,您甚至可以安全使用

请问消耗更多的服务器端资源?可能,有点。这很重要吗?测量!如果您拥有值得保护的资源,将会排除会话信息泄漏,网络钓鱼,中间人攻击等全部错误。

相关问题