Chrome一直不请求HTTP/2.0

发布于 2022-09-02 20:34:52 字数 2231 浏览 35 评论 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
clipboard.png

使用Firefox

clipboard.png

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

相关链接
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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

将军与妓 2022-09-09 20:34:52

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

茶底世界 2022-09-09 20:34:52

参考下这篇文章:https://segmentfault.com/a/11...

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文