首页 > 代码库 > NGINX负载均衡
NGINX负载均衡
NGINX主服务器:192.168.128.128
server1:192.168.128.130:80
server2:192.168.128.131:80
1.安装NGINX
yum -y install gcc pcre-devel zlib-devel openssl-develtar -zxvf nginx-1.10.1.tar.gzcd nginx-1.10.1./configure --prefix=/usr/local/nginx --with-http_realip_module --with-http_sub_module --with-http_gzip_static_module --with-http_stub_status_modulecd /usr/local/nginxvim /usr/local/nginx/conf/nginx.confupstream myServer{ server 192.168.128.130:80; server 192.168.128.131:80; } server { listen 80; server_name 192.168.128.128; #charset koi8-r; #access_log logs/host.access.log main; location / { proxy_pass http://myServer; #proxy_set_header Host $host; #proxy_set_header X-Real-IP $remote_addr; ;#防止ajax安全请求问题 #proxy_set_header REMOTE-HOST $remote_addr; ;#防止ajax安全请求问 #root html; #index index.html index.htm; }[root@localhost conf]# /usr/local/nginx/sbin/nginx -t[root@localhost conf]# /usr/local/nginx/sbin/nginx[root@localhost conf]# /usr/local/nginx/sbin/nginx -s stop
到此 就可以了轮询 130和131了。
yum -y install gcc pcre-devel zlib-devel openssl-develtar -zxvf nginx-1.10.1.tar.gzcd nginx-1.10.1
./configure \--prefix=/usr/local/nginx \--with-http_realip_module \--with-http_sub_module \--with-http_gzip_static_module \--with-http_stub_status_module
cd /usr/local/nginx
[root@localhost conf]# /usr/local/nginx/sbin/nginx[root@localhost conf]# /usr/local/nginx/sbin/nginx -t[root@localhost conf]# /usr/local/nginx/sbin/nginx -s stop
NGINX负载均衡
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。