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
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
相关文章推荐
- nginx的502错误及常见解决方法汇总
- Nginx安装手冊以及图片server部署
- Centos7 Nginx安装
- nginx配置虚拟主机之不同端口和不同IP地址
- nginx配置虚拟主机之基于域名
- nginx使用问题记录
- nginx1.8编译安装
- Nginx 权威解读
- nginx的gzip压缩功能的配置
- Nginx学习之六-nginx核心进程模型
- Nginx源码分析-启动初始化过程(一)
- nginx Makefile中添加编译自定义模块
- nginx性能优化技巧
- Nginx学习笔记二 -- nginx的配置
- Nginx学习笔记一
- 整理下ubuntu系统下用symfony新建web项目的环境搭建以及一些问题
- 为PHP设置服务器(Apache/Nginx)环境变量
- zabbix监控nginx 状态
- Apache与Nginx的优缺点
- 源码安装nginx