nginx初步负载均衡
来源:互联网 发布:博尔量化源码 编辑:程序博客网 时间:2024/06/14 00:33
vm镜像:centos6.6
域名服务已配好
web01ip:192.168.146.134 www.abc.cn/bbs.abc.cn
web02ip:192.168.146.135 www.abc.cn/bbs.abc.cn
nginx主配ip:192.168.146.132
nginx副配ip:192.168.146.133
1.对web01和web02主机nginx配置:
1.1 编译安装nginx后
cd /application/nginx/
1.2 mkdir html/{www bbs}
echo "web01 www.abc,cn">html/www/index.html
echo "web01 bbs.abc,cn">html/bbs/index.html
同样在web02主机建立
echo "web02 www.abc,cn">html/www/index.html
[root@web01 nginx]# cat conf/nginx.confworker_processes 1;events { worker_connections 1024;}http { include mime.types; default_type application/octet-stream; sendfile on; keepalive_timeout 65; log_format main '$remote_addr - $remote_user [$time_local] "$request" ' '$status $body_bytes_sent "$http_referer" ' '"$http_user_agent" "$http_x_forwarded_for"'; server { listen 80; server_name www.abc.cn; location / { root html/www; index index.html index.htm; } access_log logs/www.access.log main;} server { listen 80; server_name bbs.abc.cn; location / { root html/bbs; index index.html index.htm; } access_log logs/bbs.access.log main;}}
/application/nginx/sbin/nginx -t
......is ok
启动:(不启动会报invalid pid ...nginx.pid之类的)
/application/nginx/sbin/nginx
1.2加入web01/web02主机解析
[root@localhost ~]# cat /etc/hosts192.168.146.134 www.abc.cn192.168.146.134 bbs.abc.cn
2.对nginx主配和nginx副配nginx.conf编辑相同如下:
[root@localhost nginx]# cat conf/nginx.confworker_processes 1;events { worker_connections 1024;}http { include mime.types; default_type application/octet-stream; sendfile on; keepalive_timeout 65; upstream www_server_pools{#<==定义web服务器池,包含134,135两个web节点 server 192.168.146.134:80 weight=1; server 192.168.146.135:80 weight=1;} server {#<==定义代理的负载均衡域名虚拟主机 listen 80; server_name www.abc.cn; location / { proxy_pass http://www_server_pools;#<==访问www.abc.cn,请求发送给www_server_pools里的节点} }}
2.1对ip192.168.146.132主配nginx编辑:
echo “192.168.146.132 www.abc.cn” >/etc/hosts
curl www.abc.cnweb01 www.abc,cncurl www.abc.cnweb02 www.abc,cn
0 0
- nginx初步负载均衡
- nginx负载均衡【nginx】
- nginx配置负载负载均衡
- nginx负载均衡
- Nginx负载均衡
- Nginx 负载均衡 简介
- nginx 负载均衡配置
- Nginx负载均衡
- nginx 负载均衡测试
- Nginx实现负载均衡
- Nginx负载均衡
- 解析Nginx负载均衡
- Nginx负载均衡
- nginx 实现负载均衡
- 【NGINX】负载均衡(upstream)
- nginx 负载均衡
- Nginx 负载均衡示例
- Nginx负载均衡
- UGUI优化:批次合并源码分析及工具
- html,js自助打字代码
- rails 字符串的一些小技巧
- Intellij idea的go代码自动格式化
- c语言 数左右移的问题
- nginx初步负载均衡
- Visual Studio Ultimate 2013 Update5 中文版/英文版 下载 CD-KEY
- 2017/4/6
- AT指令集
- 用java实现自动创建文件及文件夹
- Unity3D BoxRunner游戏 源码下载
- jquery简洁版的banner图轮播
- 程序员避免久坐,站着的"俯卧撑"
- Apple的LZF算法解析