说明

http重定向为https本来是一个好的方案,毕竟https更安全,但是有的情况下我们真的只需要http访问。这时候Chrome默认的重定向就会导致问题。
比如我的博客,图床用的是http协议访问,但是Chrome重定向了之后就会导致所有的图片都访问不了,因此我们还是需要访问http的。

chrome浏览器解决

现在已经无法保证能生效了,偶尔能生效

1
> 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.

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

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

  • chrome

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

    引用

    现在已经证实只是概率性的解决了,真烦。。。。。。
    还是看看Nginx配置解决吧

nginx 配置解决

如果你服务端使用的是nginx,那么可以配置Nginx的重定向,将https重定向成http,也可以解决

使用Nginx的**return 301 http://blog.liukewen.cn$request_uri**,采用301 或 302重定向都可以

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
server {
listen 443 ssl;

server_name blog.liukewen.cn;

return 302 http://blog.liukewen.cn$request_uri;

# 证书申请见 申请letsEncryp证书及一键部署nginx,可以一键部署泛域名
ssl_certificate <cert位置>;
ssl_certificate_key <key位置>;

ssl_session_cache shared:SSL:10m;
ssl_session_timeout 5m;

ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:ECDHE:ECDH:AES:HIGH:!NULL:!aNULL:!MD5:!ADH:!RC4;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2 TLSv1.3;

ssl_prefer_server_ciphers on;
}