Phi*_*ifo 40 apache ssl https ruby-on-rails hsts
我有一个Rails应用程序config.force_ssl = true,但现在我不想要SSL加密,但我的应用程序仍然重定向到https.我读到这是Apache上的HTTP严格传输安全问题.我该如何禁用它?
Bru*_*uno 70
这不是Apache的问题,而是Rails发送HSTS头的事实.
在Chrome中,您可以通过进入about:net-internals,清除HSTS状态,如Chrome中的ImperialViolet:HSTS UI中所述.您可能还必须清除缓存,因为config.force_ssl = true还使用301(永久)重定向.
此外,根据此答案,您还可以使应用程序发送max-age = 0的STS标头.在你的控制器中:
response.headers["Strict-Transport-Security"] = 'max-age=0'
Run Code Online (Sandbox Code Playgroud)
tim*_*son 17
只想指出@ Bruno的答案,@ JoeVanDyk的建议是正确的,可以在Rails/Apache的上下文之外应用.我正在使用PHP和Nginx.在我的情况下,PHP与它无关,但这是Nginx的步骤:
//sorry here's the nginx.conf part first, can't figure out how to mix multi-line
//code with an ordered list
server {
#...
#change:
# add_header Strict-Transport-Security "max-age=315360000; includeSubdomains";
#to:
add_header Strict-Transport-Security "max-age=0;";
#...
}
Run Code Online (Sandbox Code Playgroud)
清除你的"浏览器历史记录".为了澄清@ JoeVanDyk的建议,我认为您需要清除"浏览历史记录",因为清除缓存对我不起作用(在Chrome/Firefox上测试,如果您了解更多,请添加评论).
nginx.conf文件(参见上面的代码)
重启服务器
root@ip-xxx-xxx-xxx:~# /etc/init.d/nginx restart.
在此之后,您可以将nginx add_header Strict..命令恢复为之前的状态.只需确保再次重复步骤1-3.