AI (1) mastodon (2) matrix (1) 加密 (3) 境内卡 (1) 境内游 (13) 境外卡 (14) 境外游 (6) 工作 (3) 工作小结 (1) 旅行 (21) 无人机 (1) 服务器 (9) 生活 (10) 美股 (1)

解决反向代理后部分浏览器can’t parse response报错问题

昨天不是给博客套上了一个日本节点的反向代理么,昨晚用CHROME测试正常,SAFARI不正常,我还以为是缓存的问题

今天发现IOS的默认浏览器也出现了同样的报错“can’t parse response”,觉得可能不是某个浏览器缓存问题了,就在网上到处搜索了一下,最终找到了解决办法(https://trac.nginx.org/nginx/ticket/915)这里记录一下。

问题原因:

When proxying an HTTP/2-enabled webserver with nginx, nginx fetches resources using HTTP/1.1, which the backend server tries to upgrade to HTTP/2 by sending the “Upgrade: h2” header.
In the default configuration, this header is then forwarded to the client, which is incorrect.
In the case of nghttp, this is interpreted as an error:

翻译一下:

当使用 nginx 代理一个支持 HTTP/2 的 web 服务器时,nginx 使用 HTTP/1.1 获取资源,而后端服务器尝试通过发送 “Upgrade: h2” 头部来升级到 HTTP/2。 在默认配置中,这个头部随后被转发给客户端,这是不正确的。 在 nghttp 的情况下,这被解释为一个错误。

解决方法:

在反向代理配置文件中,添加如下代码

proxy_hide_header      Upgrade;

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注

zh_CNZH_CN