firefox - Chrome一直不请求HTTP/2.0

查看:416
本文介绍了firefox - Chrome一直不请求HTTP/2.0的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

问 题

nginx已经正确配置http2 但是chrome访问的时候总是请求HTTP 1.1,
但用safari和firefox访问时是2.0。

stackoverflow传送门
http://stackoverflow.com/questions/37717417/chrome-51-0-2704-84-not-requesting-http-2-0-but-safari-an-firefox-did

nginx版本1.10.0
Chrome版本51.0.2704.84
Safari版本9.1.1
Firefox版本47.0

Chrome已经尝试清除缓存,但无效

配置文件

worker_processes 2;
events {
    worker_connections 1024;
    multi_accept on;
    use epoll;
}

http {
    sendfile on;

    server {
        listen 80;
        location / {
            return 301 https://$host$request_uri;
        }
    }

    server {
        listen 443 ssl http2;

        ssl_certificate     /usr/cer/server.cer;
        ssl_certificate_key /usr/cer/server.key;

        location / {
            root   /usr/share/nginx/html;
            index  index.html;
        }
    }
}

日志信息
上面是Chrome访问,下面是Safari

使用Firefox

====================== 朴素的分割线 =========================

相关链接
https://www.nginx.com/blog/supporting-http2-google-chrome-users/
https://imququ.com/post/enable-alpn-asap.html

楼主已经制作好了最新的nginx 1.11.1镜像(包括 openssl 1.0.2h 模块)
docker hub: https://hub.docker.com/r/tommyzzm/nginx/tags/
github: https://github.com/tommyZZM/docker-hub/tree/master/nginx

下载 docker pull tommyzzm/nginx:1.11.1-alpine-3.3

解决方案

Chrome 51之后,放弃了对NPN的支持。也就是要求服务端支持ALPN,才能正常的协商至HTTP/2协议。需要OpenSSL 1.0.2以上版本才支持ALPN。具体可见这篇文章。为什么我们应该尽快支持 ALPN?
我的个人网站也遇到了这个问题,我的解决方案是升级至Ubuntu 16.04。另外一种解决方案是,将nginx运行在docker容器中。还有一种解决方案是,自行编译openssl和nginx。

这篇关于firefox - Chrome一直不请求HTTP/2.0的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆