mastodon (2) matrix (1) 加密 (3) 境内卡 (1) China travel (12) Foreign bank card (13) International travel (6) 工作 (2) Trip (18) dedicated server (8) Life (6)

RESOLVING THE ISSUE OF SOME BROWSERS "CAN’T PARSE RESPONSE"

Yesterday, I applied a Japanese node reverse proxy to the blog, and last night I tested it with CHROME, which worked fine, but SAFARI did not, and I thought it might be a caching issue.

Today, I discovered that the default browser on iOS also showed the same error message "can’t parse response", so I figured it might not just be a caching issue with a specific browser. After searching around online, I finally found a solution (https://trac.nginx.org/nginx/ticket/915). Here's a record of it.

The cause of the issue:

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 的情况下,这被解释为一个错误。

Solution:

In the reverse proxy configuration file, add the following code:
proxy_hide_header      Upgrade;

Leave a Reply

Your email address will not be published. Required fields are marked *

en_USEN