条件:三台虚拟主机(其中一台虚拟机需要安装nginx)
在配置文件vim /usr/local/nginx/conf/nginx.conf中添加以下内容
upstream web-server{
ip_hash;
server 192.168.226.145 fail_timeout=60s weight=3 ;
server 192.168.226.168 weight=7 ;
}
server{
listen 80;
server_name localhost;
location / {
proxy_pass http://web-server;
root html;
index index.html index.htm;
}