Safari在使用HTTP / 2时无法给出响应

时间:2016-06-11 09:33:30

标签: ssl nginx safari http2

我是nginx的新手(过去一直在使用apache)。

目前我正在尝试设置一个缓存,它将面向一个apache后端,最终我认为(基于我,迄今为止,对nginx的良好体验)我们将切换到只使用nginx。

我一打开http2 Safari就无法得到回应。在错误日志中没有任何迹象表明存在问题,如果我打开访问日志并检查那里我可以看到Safari客户端执行了很多很多连接,就像它只是不断刷新页面一样。

我已经尝试了很多nginx版本,因为我注意到最新版本可能存在问题。所以我尝试降级到1.9.14以及升级到1.11.1,也没有运气。

Nginx只用以下编译:

./configure --with-http_ssl_module --with-http_v2_module

Nginx -V输出:

nginx version: nginx/1.11.1
built by gcc 5.3.1 20160413 (Ubuntu 5.3.1-14ubuntu2.1) 
built with OpenSSL 1.0.2g-fips  1 Mar 2016
TLS SNI support enabled
configure arguments: --with-http_ssl_module --with-http_v2_module

我的配置看起来像这样(我的网站 - 可用的配置):

upstream backend {
    server 127.0.0.1:8088 weight=100;
}

server {
    listen 443 ssl http2 deferred;
    server_name www.server.name;

    ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
    ssl_ciphers "ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES256-GCM-SHA384:DHE-RSA-AES128-GCM-SHA256:DHE-DSS-AES128-GCM-SHA256:kEDH+AESGCM:ECDHE-RSA-AES128-SHA256:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA:ECDHE-ECDSA-AES128-SHA:ECDHE-RSA-AES256-SHA384:ECDHE-ECDSA-AES256-SHA384:ECDHE-RSA-AES256-SHA:ECDHE-ECDSA-AES256-SHA:DHE-RSA-AES128-SHA256:DHE-RSA-AES128-SHA:DHE-DSS-AES128-SHA256:DHE-RSA-AES256-SHA256:DHE-DSS-AES256-SHA:DHE-RSA-AES256-SHA:!aNULL:!eNULL:!EXPORT:!DES:!RC4:!3DES:!MD5:!PSK";
    ssl_prefer_server_ciphers on;

    ssl_certificate /path/to/cert.crt
    ssl_certificate_key /path/to/cert_key.key

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

    add_header Strict-Transport-Security "max-age=31536000; includeSubdomains;";

    location / {
            proxy_redirect off;
            proxy_set_header Host $host;
            proxy_set_header X-Real-IP $remote_addr;
            proxy_set_header X-Forwarded_For $proxy_add_x_forwarded_for;

            proxy_pass https://backend;
    }

}

如果我从listen参数中删除http2并重新启动它可以正常工作......

我一直在搜索我的配置是否有任何错误,但我找不到任何东西......但是,如果我的配置有一些改进,请告诉我。然而,主要的问题是每当我使用Safari点击URL(缓存或不缓存)时,它都会继续加载。

这是我的访问日志在请求后的样子:

123.123.123.123 - - [11/Jun/2016:08:37:28 +0200] "GET /example/url HTTP/2.0" 200 15032 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_4) AppleWebKit/601.5.17 (KHTML, like Gecko) Version/9.1 Safari/601.5.17"
123.123.123.123 - - [11/Jun/2016:08:37:28 +0200] "GET /example/url HTTP/2.0" 200 15032 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_4) AppleWebKit/601.5.17 (KHTML, like Gecko) Version/9.1 Safari/601.5.17"
123.123.123.123 - - [11/Jun/2016:08:37:28 +0200] "GET /example/url HTTP/2.0" 200 15032 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_4) AppleWebKit/601.5.17 (KHTML, like Gecko) Version/9.1 Safari/601.5.17"
123.123.123.123 - - [11/Jun/2016:08:37:28 +0200] "GET /example/url HTTP/2.0" 200 15032 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_4) AppleWebKit/601.5.17 (KHTML, like Gecko) Version/9.1 Safari/601.5.17"
123.123.123.123 - - [11/Jun/2016:08:37:28 +0200] "GET /example/url HTTP/2.0" 200 15032 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_4) AppleWebKit/601.5.17 (KHTML, like Gecko) Version/9.1 Safari/601.5.17"
123.123.123.123 - - [11/Jun/2016:08:37:28 +0200] "GET /example/url HTTP/2.0" 200 15032 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_4) AppleWebKit/601.5.17 (KHTML, like Gecko) Version/9.1 Safari/601.5.17"
123.123.123.123 - - [11/Jun/2016:08:37:28 +0200] "GET /example/url HTTP/2.0" 200 15032 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_4) AppleWebKit/601.5.17 (KHTML, like Gecko) Version/9.1 Safari/601.5.17"

谢谢!

1 个答案:

答案 0 :(得分:3)

奥基!经过大量的研究和测试后发现我需要在配置中隐藏Upgrade头。 proxy_hide_header Upgrade;

在此处阅读更多内容:https://trac.nginx.org/nginx/ticket/915