繁体   English   中英

带有 NGINX 的 Apache 服务器的 400 错误请求负载均衡器

[英]400 Bad Request load balancer for Apache servers with NGINX

我正在使用 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 处理请求时遇到 400 Bad Request 错误。

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

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

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

例如:

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
}

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

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM