First, the environment introduction:
Load Balancer Server (Master): 192.168.10.128 (LNMP)
Web server 1:192.168.10.144 (NGINX)
Web server 2:192.168.10.145 (NGINX)
Note: The master server uses the compiled and installed LNMP;
Both Web servers 1 and 2 have Nginx installed using only Epel's Yum source.
Second, configure the Load Balancer server
# vi /etc/nginx/nginx.confhttp { upstream www.zhi.com { server 192.168.10.144:80; server 192.168.10.145:80; } server{ listen 80; server_name www.zhi.com; root /usr/share/nginx/html/index.html; location / { proxy_pass http://www.zhi.com; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote _addr; proxy_set_ header x-forwarded-for $proxy _add_x_forwarded_for; } }}# nginx -s reload # #重载nginx # getenforce 0 # #设置SELinux becomes permissive mode # systemctl stop firewalld.service # #关闭防火墙
III. Configuring Web servers 1 and 2
① Common Configuration
# vi/etc/nginx/nginx.confserver {Listen default_server; server_name www.zhi.com; # #只需更改该处即可 root/usr/share/nginx/html;} # systemctl Stop firewalld# getenforce 0# systemctl start Nginx
②web server 1
# Vi/usr/share/nginx/html/index.html
③web server 2
# Vi/usr/share/nginx/html/index.html
Iv. Testing
Change the Hosts file
C:\Windows\System32\drivers\etc\hosts192.168.10.128 www.zhi.com
Browser input www.zhi.com for verification
650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M00/73/FF/wKiom1YLt0PS0u3EAABpTbA7ip0786.jpg "title=" QQ picture 20150930162730.png "alt=" Wkiom1ylt0ps0u3eaabptba7ip0786.jpg "/>
After refresh
650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M02/73/FC/wKioL1YLt1_SJvXjAABkO6b_l5U418.jpg "title=" QQ picture 20150930162806.png "alt=" Wkiol1ylt1_sjvxjaabko6b_l5u418.jpg "/>
Load balancing is already possible.
This article is from the Notepad blog, so be sure to keep this source http://wangzhijian.blog.51cto.com/6427016/1699643
Nginx for simple load balancing