【问题标题】:400 Bad Request load balancer for Apache servers with NGINX使用 NGINX 的 Apache 服务器的 400 Bad Request 负载均衡器
【发布时间】:2023-03-04 20:08:01
【问题描述】:

我使用 NGINX 作为 Apache WebServers (WordPress) 的负载平衡器。所有服务器均使用 AWS EC2 制作。我对 NGINX 的配置:

cat /etc/nginx/sites-available/default



upstream web_backend {
        server 35.157.101.5;
        server 35.156.213.23;
}

server {
        listen 80;
        location / {
                proxy_pass http://web_backend;
        }
}

但在 NGINX 重启后,我通过公共 ip 访问负载均衡器并收到错误:

错误请求

您的浏览器发送了此服务器无法理解的请求。

此外,在尝试 使用 ErrorDocument 来处理请求。

Apache/2.4.29 (Ubuntu) 服务器位于 ip-172-31-35-36.eu-central-1.compute.internal 端口 80

如果我刷新页面,我会收到同样的错误,但最后有另一个 ip(第二台服务器的私有 ip),所以我知道 NGINX 可以完成工作,这是 Apache 的问题。 我尝试在 nginx 配置中为我的服务器添加 80 端口,将 ips 替换为 dns 和私有 ip,但没有帮助。 Apache 上的访问日志没有显示任何有用的信息,只有 400 个错误。 可能是什么问题?

【问题讨论】:

    标签: apache nginx amazon-ec2


    【解决方案1】:

    不要使用“_”作为上游名称,这是我的问题的唯一原因。

    【讨论】:

      【解决方案2】:

      只需检查哪些端口正在运行 Apache WebServer。您必须将它们添加到您的上游。

      例如:

      upstream web_backend {
              server 35.157.101.5:8080; //assuming that your apache webserver is running on this port on this host
              server 35.156.213.23:3000;//And a different port on the other.. you still need to add them here if your ports are same
      }
      

      【讨论】:

      • 正如我所说的使用端口编辑 ip(在我的情况下它是默认的 80 端口,我检查了 Apache 运行端口)没有帮助,我得到了同样的错误。
      • 请在上游名称中使用 kebab 大小写
      猜你喜欢
      • 1970-01-01
      • 2019-01-05
      • 2017-06-12
      • 1970-01-01
      • 1970-01-01
      • 2018-09-10
      • 2014-05-03
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多