解决浏览器强制https问题


解决浏览器强制https问题

在将服务尝试着从http协议往https协议迁移成功之后,又出于测试调试的目的将服务转回到http协议,却发现在浏览器输入http会被自动跳转到https

HTTP Strict Transport Security (HSTS) is an opt-in security enhancement that is specified by a web application through the use of a special response header. Once a supported browser receives this header that browser will prevent any communications from being sent over HTTP to the specified domain and will instead send all communications over HTTPS. It also prevents HTTPS click through prompts on browsers.

查阅相关资料,发现这是浏览器的HSTSHTTP Strict Transport Security)功能引起的。在安装配置SSL证书时,可以使用一种能使数据传输更加安全的Web安全协议,即在服务器端上开启HSTS ,它会告诉浏览器只能通过HTTPS访问,而绝对禁止HTTP方式。

因此,只要关闭浏览器的HSTS功能就可以解决这个问题,但是只能通过特定的方式而不是清除浏览器缓存那么简单。

Chrome浏览器

  1. 地址栏中输入chrome://net-internals/#hsts
  2. Delete domain中输入项目的域名,并Delete(删除)。
  3. 可以在Query domain测试是否删除成功。

具体页面

在最下面的Delete domain security policies里输入想要删除的网址,注意是去掉http://前缀的网址,如:h5.baidu.com

edge浏览器

  1. 地址栏输入edge://net-internals/#hsts
  2. 接着操作同Chrome浏览器

文章作者: 念心卓
版权声明: 本博客所有文章除特別声明外,均采用 CC BY 4.0 许可协议。转载请注明来源 念心卓 !
  目录