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

nginx 负载均衡配置

2015-12-19 22:01 543 查看
yum或者源码安装nginx,在nginx/conf/vhosts下新建配置文件test.conf(前提是在主配置文件中nginx.conf增加include hosts/*.conf)
upstream test {
ip_hash;
server 192.168.31.100(服务器1IP);
server 192.168.31.101(服务器2IP);
}
#IP后可支持权重,weight=2等

server {
listen 80;
server_name bbs.aaa.cn;#定义域名用于访问

location / {
proxy_pass http://test/; #为上面upstream 定义的别名
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
}

本文出自 “沏茶品香” 博客,请务必保留此出处http://chinawu.blog.51cto.com/10692884/1726436
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: