【发布时间】:2014-08-29 13:16:52
【问题描述】:
我目前有一个基于 Rails 的 Web 应用程序,它需要通过 HTTP 提供一小部分页面 - 但更喜欢通过 HTTPS 提供其余页面。在我当前的 AWS 设置中,SSL 终止于弹性负载均衡器,并且与我的应用服务器的所有通信都通过 HTTP。因此,Rack SSL Enforcer 之类的解决方案并不合适。目前,我在每个页面中提供以下 JS sn-p 来处理重定向:
<% if should_be_ssl? %>
<script>
if (window.location.protocol != "https:"){
window.location.href = "https:" + window.location.href.substring(window.location.protocol.length);
}
</script>
<% else %>
<script>
if (window.location.protocol != "http:"){
window.location.href = "http:" + window.location.href.substring(window.location.protocol.length);
}
</script>
<% end %>
每次访问这些页面之一时,都会对性能造成相对显着的影响。有谁知道通过 SSL 选择性地提供某些页面并在负载均衡器级别控制它的方法?
【问题讨论】:
标签: ruby-on-rails ssl amazon-web-services https amazon-elb