HTTP 426 与 nginx 代理传递

Ste*_*son 5 https reverse-proxy nginx

我在 nginx 配置中使用以下内容来代理对单独静态网站服务器的特定路径的请求。

server {
  listen 80;
  server_name _ localhost; # need to listen to localhost for worker tier

  location / {
    proxy_pass https://mywebsite.com;
    proxy_set_header Host mywebsite.com;
    proxy_set_header X-Real-IP $remote_addr;
  }

}
Run Code Online (Sandbox Code Playgroud)

第一次/team访问该路径时,它工作正常。但后续请求会导致HTTP 426Chrome 出错。在隐身窗口中打开它效果很好,但有时也会出现 426 错误。

nginx 错误日志中没有与此相关的错误。426 文档并不能帮助我们解决这个问题。

Nginx 在 ElasticBeanstalk 环境中运行,该环境使用应用程序负载均衡器,该负载均衡器接受 HTTP / HTTPS 请求并将它们转发到应用程序实例的端口 80。

小智 3

自从提出这个问题以来已经有一段时间了,但我最近遇到了类似的问题,而且我很快就发现了这个问题。对我来说成功的解决方案是: https: //github.com/envoyproxy/envoy/issues/2506#issuecomment-362558239

我添加了proxy_http_version 1.1;到位置块:

location / {
 proxy_pass https://mywebsite.com;
 proxy_http_version 1.1;
 proxy_set_header Host mywebsite.com;
 proxy_set_header X-Real-IP $remote_addr;
}
Run Code Online (Sandbox Code Playgroud)