启用 HTTP2 的 Nginx 下载所有内容

启用 HTTP2 的 Nginx 下载所有内容

我最近将 nginx 更新到 1.9.7,它支持 http2。

在我的某个虚拟主机中启用 http2 时,nginx 应该从该虚拟主机提供的每个页面都会被下载。我在最新版本的 Chrome、Safari 和 Android 版 Chrome 上对此进行了测试。所有测试的结果都相同,即下载并保存我导航到的页面名称,即使该页面实际上并不存在于服务器上。计算机上保存的页面从未包含服务器上的实际内容。它是一个包含相同、奇怪的 1kb 字符串的奇怪文件)。我尝试测试不同的扩展,以确保它不是 php-fpm 的问题,每个扩展都下载了。

虚拟主机配置:

server {
    listen          <ip>:80 http2;
    server_name     testsite.dev;

    index   index.php index.html index.htm;
    root /home/sites/test/www;

    access_log /var/log/nginx/sites/testsite-access_log;
    error_log /var/log/nginx/sites/testsite-error_log;

#   location / {
#               try_files $uri $uri/ /index.php;
#   }

    location = /favicon.ico {
            access_log off;
            log_not_found off;
    }

    gzip off;

    location ~ \.php$ {
            try_files $uri =404;
            include /etc/nginx/fastcgi_params;
            fastcgi_pass unix:/var/run/php-fpm/testsite.socket;
            fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
            fastcgi_param PATH_INFO $fastcgi_path_info;
            fastcgi_param open_basedir "/home/sites:/tmp:/usr/share/pear:/var/lib/php/session/";
    }

}

http2如果我从指令中删除listen,则该站点将 100% 按预期运行并正常提供文件。

对为什么会发生这种情况有任何见解吗?搜索 Google 似乎只会得到有关正在下载 .php 文件的结果(由错误配置的 php-fpm 引起)。

编辑:下载的文件始终包含以下内容:

在 TextEdit 中打开时:

ġˇˇˇˇˇˇ

在 Sublime Text 3 中打开时:

0000 1204 0000 0000 0000 0300 0000 8000
047f ffff ff00 0500 ffff ff00 0004 0800
0000 0000 7fff 0000 0000 0807 0000 0000
0000 0000 0000 0000 01

答案1

通常 http2 需要通过 ssl/tls 运行,chrome 和 Firefox 都只支持加密的 http2。

在将 http/2 添加到 ssl 时是否会出现同样的错误 listen 443 ssl http2

相关内容