Nginx returns 426

Nginx returns 426

当我使用 curl 从 Nginx 服务器访问 Istio 网关 NodePort 时,我得到了正确的响应,如下所示:

curl -v "http://52.66.195.124:30408/status/200"
*   Trying 52.66.195.124:30408...
* Connected to 52.66.195.124 (52.66.195.124) port 30408 (#0)
> GET /status/200 HTTP/1.1
> Host: 52.66.195.124:30408
> User-Agent: curl/7.76.1
> Accept: */*
> 
* Mark bundle as not supporting multiuse
< HTTP/1.1 200 OK
< server: istio-envoy
< date: Sat, 18 Sep 2021 04:33:35 GMT
< content-type: text/html; charset=utf-8
< access-control-allow-origin: *
< access-control-allow-credentials: true
< content-length: 0
< x-envoy-upstream-service-time: 2
< 
* Connection #0 to host 52.66.195.124 left intact

当我像下面这样通过 Nginx 代理配置时,我通过域获得 HTTP ERROR 426

注意:我的域是 HTTPS - https://dashboard.example.com

server {
        server_name dashboard.example.com;
        location / {
               proxy_pass       http://52.66.195.124:30408;
        }
}

任何人都可以帮助我理解这个问题吗?

HTTP 426 错误表示 upgrade required:

The server refuses to perform the request using the current protocol but might be willing to do so after the client upgrades to a different protocol.

another info:

The HTTP 426 Upgrade Required client error response code indicates that the server refuses to perform the request using the current protocol but might be willing to do so after the client upgrades to a different protocol.

根据您的情况,您需要检查您使用的 HTTP 协议的版本。似乎太低了。看看this thread。在这种情况下,您必须从 1.0 升级到 1.1

您需要在 NGINX 配置中升级您的 HTTP 协议版本:

This route is for a legacy API, which enabled NGINX cache for performance reason, but in this route's proxy config, it missed a shared config proxy_http_version 1.1, which default to use HTTP 1.0 for all NGINX upstream.

And Envoy will return HTTP 426 if the request is HTTP 1.0.