步骤:
1 [root@localhost ~]# vim /usr/local/nginx-1.12.0/conf/nginx.conf
[root@localhost ~]# cp /usr/local/nginx-1.12.0/conf/nginx.conf /usr/local/nginx-1.12.0/conf/nginx1.conf
[root@localhost ~]# vim /usr/local/nginx-1.12.0/conf/nginx1.conf
[root@localhost ~]# vim /usr/local/nginx-1.12.0/html/index.html
[root@localhost ~]# cd /usr/local/nginx-1.12.0/sbin/
[root@localhost sbin]# /usr/local/nginx-1.12.0/sbin/nginx -c /usr/local/nginx-1.12.0/conf/nginx.conf
[root@localhost sbin]# /usr/local/nginx-1.12.0/sbin/nginx -c /usr/local/nginx-1.12.0/conf/nginx1.conf
修改nginx.conf
upstream songwei{
server 192.168.16.39:8080;
server 192.168.16.110:8080;#在http和server之间加入这个模块
server 192.168.16.121:8080;
}
##后面的serever也得改
nginx.conf的server
server {
listen 80;
server_name localhost;
#charset koi8-r;
#access_log logs/host.access.log main;
location / {
proxy_pass http://songwei;
# root html;
#index index.html index.htm;
}
修改nginx1.conf(第一个从机)因为我主机作为代理服务器和从机1,所以这样设置
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