我用vmware+centos做了3個虛拟機,用nginx做負載均衡。
分别是192.168.8.128,192.168.8.129,192.168.8.130
3台虛拟機上都安裝了nginx
192.168.8.128 作為代理伺服器
192.168.8.129,192.168.8.130 這2台伺服器提供的内容都是隻有一個靜态的index.html檔案
單獨通路這2台伺服器都可以打開
如果代理伺服器配置修改成proxy_pass http://192.168.8.129:80; 通路192.168.8.128會顯示http://192.168.8.129下的網頁内容
但是代理伺服器如果用upstream,配置檔案如下:
upstream proxy_servers
{
server 192.168.8.129:80;
server 192.168.8.130:80;
}
server
{
listen 80;
server_name localhost;
index index.html;
location / {
proxy_pass http://proxy_servers;
}
}
通路192.168.8.128總是502錯誤。日志都是:
upstream prematurely closed connection while reading response header from upstream
或:
no live upstreams while connecting to upstream
selinux 和防火牆都關閉了。
不知道怎麼解決問題