nginx反向代理三台web服务器,实现负载均衡

修改nginx.conf

#在http和server之间加入这个模块 
upstream guaji{
server 127.0.0.1:8080;
server 127.0.0.2:8080;
server 127.0.0.3:8080; }

nginx.conf的server

server {
  listen 80;
  server_name localhost; #charset koi8-r; #access_log logs/host.access.log main; location / {
   proxy_pass http://guaji;
    # root html;
    #index index.html index.htm; }
}
修改nginx1.conf
server {
        listen       8080;
server_name localhost; #charset koi8-r; #access_log logs/host.access.log main; location / { root html;
index index.html index.htm; }
}

修改nginx.conf(第二个从机)

server {
listen 8080;#只修改这里
server_name localhost; #charset koi8-r; #access_log logs/host.access.log main; location / {
root html;
index index.html index.htm; }
}

同理修改第三个从机的nginx.conf

修改index.html

然后重启就ok

猜你喜欢

转载自www.cnblogs.com/ldcheng/p/9203978.html