您的位置:首页 > 运维架构 > Nginx

nginx负载均衡之配置和策略

2017-03-22 19:00 417 查看
关于nginx的负载均衡策略,在这里不多说,请见参考文章:

http://blog.csdn.net/xiajun07061225/article/details/9318871
http://blog.csdn.net/xiajun07061225/article/details/9334477
nginx配置参考文章:

http://www.cnblogs.com/oshine/p/3953259.html

http://www.cnblogs.com/jacktang/p/3669115.html

准备工作:三台配置好的服务器(centos7.0 + mysql5.7 + php7.0 + nginx/1.10.3)

配置nginx.cong文件

[root@localhost conf]# vim /usr/local/nginx/conf/nginx.conf


在http段配置(采用hash策略):
upstream cluster{
server 192.168.2.8:80;
server 192.168.2.23:80;
ip_hash;
}

在server端配置:

server {
listen 80;
server_name cluster;
location / {
proxy_pass http://cluster/; 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服务,访问http://localhost/index.php
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: