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

nginx 负载均衡

2015-07-29 17:47 656 查看

操作环境

nginx 服务器

[root@nginx ~]# cat /etc/redhat-release
CentOS release 6.5 (Final)


web 服务器 1

[root@web ~]# cat /etc/redhat-release
CentOS release 6.5 (Final)


web 服务器 2

[root@web-2 ~]# cat /etc/redhat-release
CentOS release 6.5 (Final)


web 服务器 页面 1



web 服务器 页面 2



nginx 服务器配置

nginx配置
[root@nginx ~]# vi /etc/nginx/nginx.conf


# 负载均衡测试
upstream webservers {
server 123.59.74.187 weight=1;
server 123.59.75.157 weight=1;
}

# 反向代理测试
server {
listen  2000;
location / {
proxy_pass      http://webservers; proxy_set_header    Host $host;
proxy_set_header    X-Real-IP       $remote_addr;
}
}


重新加载nginx配置
[root@nginx ~]# nginx -s reload


访问nginx服务器地址 2000端口 两个页面交替出现

页面 1



页面 2

内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  nginx 负载均衡