简体   繁体   English

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

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

I am using NGINX as load balancer for Apache WebServers (WordPress).我正在使用 NGINX 作为 Apache WebServers (WordPress) 的负载均衡器。 All servers are made with AWS EC2.所有服务器均使用 AWS EC2 制作。 My config for NGINX:我对 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;
        }
}

But after NGINX restart i am access load balancer via public ip and getting an error:但是在 NGINX 重新启动后,我通过公共 ip 访问负载均衡器并收到错误:

Bad Request错误的请求

Your browser sent a request that this server could not understand.您的浏览器发送了此服务器无法理解的请求。

Additionally, a 400 Bad Request error was encountered while trying to use an ErrorDocument to handle the request.此外,在尝试使用 ErrorDocument 处理请求时遇到 400 Bad Request 错误。

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

If i refresh page i am getting same error but with another ip in the end (second server's private ip), so i understand that NGINX do the work and it is Apache problem.如果我刷新页面我得到同样的错误,但最后有另一个 ip(第二个服务器的私有 ip),所以我知道 NGINX 可以完成工作,这是 ZE9713AE04A02A810D6F33DD956F4279 问题。 I tried to add 80 port for my servers in nginx config, replace ips with dns and private ip, but it didn't help.我尝试在 nginx 配置中为我的服务器添加 80 端口,用 dns 和私有 ip 替换 ips,但它没有帮助。 Access log on Apache doesn't show anything useful, just 400 errors. Apache 上的访问日志没有显示任何有用的信息,只有 400 个错误。 What could be the problem?可能是什么问题呢?

Just check on which ports are the Apache WebServers Running.只需检查哪些端口正在运行 Apache WebServers。 You have to add those to your upstreams.您必须将它们添加到您的上游。

Eg:例如:

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
}

Don't use '_' for upstream name, it was the only reason for my problem.不要使用 '_' 作为上游名称,这是我的问题的唯一原因。

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

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