javascript - net::ERR_CONNECTION_CLOSED 错误在 Chrome 与 HTTP2.0 + Nginx

标签 javascript google-chrome nginx

当我尝试通过 https 在服务器(使用 jQuery 或 Dropzone.js)上发布图像时如何处理 Google Chrome (v.51.0) 中的 net::ERR_CONNECTION_CLOSED 错误。

Firefox 在 http 和 https 上运行良好。 Chrome 只有 http。没有文件上传的一切在 Chrome+HTTPS 上都可以正常工作。 php 超时结束后出现此错误:

dropzone.min.js:1 POST https://{example.com}/images/upload net::ERR_CONNECTION_CLOSED

没有其他消息。 PHP 和 Nginx 日志中没有任何内容。

我的服务器:PHP 7.0.9 + Nginx 1.10 + Ubuntu Server 16.04 + 带有 Comodo SSL 证书的 HTTP2.0。

已更新

I found the problem and solution.

最佳答案

这是一种变通方法,而不是问题的解决方案。 当使用启用了 http2 的 nginx 时,我在 chrome 中发生了这个错误。

我能够在 nginx 中禁用 http2(或者更确切地说,只是删除启用它的选项)。

我改变了:

  server {
      listen 443 http2 ssl;
      listen [::]:443 http2 ssl;

到:

  server {
      listen 443 ssl;
      listen [::]:443 ssl;

在那之后,chrome 与 nginx 一起工作得很好。

我的问题特别奇怪的是,它只发生在我传递超过大约 500 字节的大 header 时。在所有其他时间,chrome/ngnx 表现得很好。在整个过程中,curl 也能很好地达到我的终点。此外,当我绕过 nginx 直接访问端点时,chrome 和我测试的所有其他浏览器都运行良好。

根据我所看到的情况,我怀疑这是 ALPN 的问题。可能是因为我的 openssl 版本已经过时了。不过,降级到 http 1.1 比研究这种可能性更容易。

关于javascript - net::ERR_CONNECTION_CLOSED 错误在 Chrome 与 HTTP2.0 + Nginx,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38752691/

相关文章:

javascript - 无法将元素的设置值设置为 "innerHTML"

google-chrome - chrome 扩展弹出窗口和背景 ajax

php - 为什么我的 MySQL 连接每天晚上都会失败?

amazon-web-services - 如何在部署应用程序 Elastic beanstalk 上修改 NGINX 配置

ubuntu - 自动化 nginx/passenger 安装

javascript - ng-repeat 表中的 Angularjs 复选框

javascript - 为什么在 React 中为一个组件同时创建 index.js 和 Component.js?

javascript - 在 Angular 中编译 HTML 字符串模板

javascript - 如何在同一扩展名的manifest.json文件中为多个内容脚本指定不同的匹配模式

javascript - Webstorm 不刷新修改后的 JavaScript 文件