tengine模块
来源:互联网 发布:投资公司让干网络销售 编辑:程序博客网 时间:2024/06/05 17:50
tengine模块
操作前提:
1、安装tomcat
1.1、安装ip为192.168.230.10的主机的tomcat
[root@node1 software]# tar -zxvf apache-tomcat-7.0.61.tar.gz -C /opt/modules[root@node1 software]# cd /opt/modules/apache-tomcat-7.0.61/webapps/ROOT[root@node2 ROOT]# vi index.jsp<html> <h1>Matrix</h1></html>进入tomcat目录[root@node1 ROOT]# cd /opt/modules/apache-tomcat-7.0.61/bin启动tomcat[root@node1 bin]# ./startup.sh
在地址行输入检查页面是否能正常显示:http://192.168.230.10:8080/
1.2、安装ip为192.168.230.11的主机的tomcat
[root@node2 software]# tar -zxvf apache-tomcat-7.0.61.tar.gz -C /opt/modules[root@node2 software]# cd /opt/modules/apache-tomcat-7.0.61/webapps/ROOT[root@node2 ROOT]# vi index.jsp<html> <h1>Matrix2</h1></html>[root@node2 ROOT]# cd /opt/modules/apache-tomcat-7.0.61/bin[root@node2 bin]# ./startup.sh
在地址行输入检查页面是否能正常显示:http://192.168.230.11:8080/
2、配置nginx访问禁止允许
2.1、进入tengine的conf目录下
[root@node1 ~]# cd /opt/modules/tengine-2.1.0/conf
2.2、编辑nginx.conf文件
[root@node1 conf]# vi nginx.confserver { listen 80; server_name www.sparsematrix.com; location / { deny 192.168.230.10; allow 192.168.230.0/24; deny all; root /opt/html; index index.html index.htm; } error_page 500 502 503 504 /50x.html; location = /50x.html { root html; } }
2.3、查看nginx访问禁止配置是否成功
在地址栏输入:http://192.168.230.10/
在地址栏输入:http://192.168.230.18/
3、配置nginx用户认证
用户认证访问 模块ngx_http_auth_basic_module 允许使用"HTTP基本认证"协议验证用户名和密码来限制对资源的访问。location / { auth_basic "closed site"; auth_basic_user_file /var/users;}Apache发行包中的htpasswd命令来创建user_file 文件htpasswd -c -m /var/users username注:需要安装httpd才可以使用上面命令
3.1、使用yum安装httpd
[root@node1 ~]# yum install httpd
3.2、编辑nginx.conf文件
[root@node1 conf]# vi nginx.conf server { listen 80; server_name www.sparsematrix.com; location / { root /opt/html; index index.html index.htm; auth_basic "Hello!"; auth_basic_user_file /opt/modules/htpasswd; } error_page 500 502 503 504 /50x.html; location = /50x.html { root html; } location /basic_status { stub_status on; } }
3.3、Apache发行包中的htpasswd命令来创建user_file 文件
[root@node1 ~]# htpasswd -m -c /opt/modules/htpasswd tomNew password: Re-type new password: Adding password for user tom[root@node1 ~]# cd /opt/modules/tengine-2.1.0/conf[root@node1 conf]# rm -rf .nginx.conf.swp
3.4、重新加载nginx服务
[root@node1 init.d]# service nginx reload
3.5、在浏览器地址栏中输入:http://192.168.230.10/
身份认证成功页面显示:
4、配置nginx访问状态监控
4.1、进入tengine的conf目录
[root@node1 ~]# cd /opt/modules/tengine-2.1.0/conf
4.2、编辑nginx.conf文件
[root@node1 conf]# vi nginx.confserver { listen 80; server_name www.sparsematrix.com; location / { root /opt/html; index index.html index.htm; } location /status { stub_status on; } error_page 500 502 503 504 /50x.html; location = /50x.html { root html; }}
4.3、在浏览器地址栏中输入:http://192.168.230.10/status
5、配置nginx反向代理
5.1、进入tengine的conf目录
[root@node1 ~]# cd /opt/modules/tengine-2.1.0/conf
5.2、编辑nginx.conf文件
[root@node1 conf]# vi nginx.confserver { listen 80; server_name www.sparsematrix.com; location / { proxy_pass http://192.168.230.11:8080; } error_page 500 502 503 504 /50x.html; location = /50x.html { root html; }}
5.3、重新加载nginx服务
[root@node1 init.d]# service nginx reload
5.4、在地址行输入检查页面是否能正常显示:http://192.168.230.10/
页面显示的是http://192.168.230.11中的内容
6、配置nginx负载均衡
6.1、进入tengine的conf目录
[root@node1 ~]# cd /opt/modules/tengine-2.1.0/conf
前提:保证192.168.230.10:8080、192.168.230.11:8080都能正常运行
6.2、编辑nginx.conf文件
[root@node1 conf]# vi nginx.conf upstream sparsematrix { server 192.168.230.10:8080 weight=1; server 192.168.230.11:8080 weight=1; } server { listen 80; server_name www.sparsematrix.com; location / { proxy_pass http://sparsematrix; }}
6.3、重新启动nginx服务
[root@node1 init.d]# service nginx stopStopping nginx: [ OK ][root@node1 init.d]# service nginx startStarting nginx: [ OK ]
6.4、在地址行输入检查页面是否能正常显示:http://192.168.230.10/
访问一次显示:
在访问一次显示:
7、tengine新增健康检查模块
7.1、进入tengine的conf目录
[root@node1 ~]# cd /opt/modules/tengine-2.1.0/conf
7.2、编辑nginx.conf文件
[root@node1 conf]# vi nginx.conf upstream sparsematrix { server 192.168.230.10:8080 weight=1; server 192.168.230.11:8080 weight=1; check interval=3000 rise=2 fall=5 timeout=1000 type=http; check_http_send "HEAD / HTTP/1.0\r\n\r\n"; check_http_expect_alive http_2xx http_3xx; } server { listen 80; server_name www.sparsematrix.com; location / { proxy_pass http://sparsematrix; } location /status { check_status; }}
7.3、在地址行输入:http://192.168.230.10/status对tomcat服务器进行健康检查
访问显示两台tomcat都没有响应:
重新启动两台tomcat
再次访问http://192.168.230.10/status显示两台tomcat运行正常:
0 0
- tengine模块
- Tengine的健康检查模块
- Tengine健康检查模块配置
- Tengine
- Tengine
- Nginx模块之SessionSticky (淘宝的tengine)
- Tengine的自助式模块编译和兼容性测试设计思路
- 六.Tengine的footer模块(ngx_http_footer_filter_module),主机信息调试
- tengine后话
- 安装Tengine
- Tengine 配置
- Tengine介绍
- tengine安装
- 安装 tengine
- tengine安装
- tengine安装
- tengine安装
- Nginx/Tengine
- 数据存储2--SharedPreferences
- poj1018 动态规划
- iOS打包Archive上传到fir.im
- 税收特征
- 集合类
- tengine模块
- 排序算法个人笔记1
- Codeforces Round #343 (Div. 2) D. Babaei and Birthday Cake(线段树+dp)
- obj_msgSend参数不能填写
- 【杭电】[2049]不容易系列之(4)——考新郎
- UVa 1220 Party at Hali-Bula dp:树的最大独立集
- 写了个MySQL数据备份小工具,放出来跟大家分享一下,欢迎拍砖。
- 转:静态方法是实例方法的区别
- MYSQL语句对于limit常用用法的讲解