首页 技术 正文
技术 2022年11月9日
0 收藏 561 点赞 3,648 浏览 1358 个字

环境说明:
nginx 反向代理服务器 ip 为: 10.219.24.26
tomcat1 应用服务器 ip 为: 10.219.24.21
tomcat3 应用服务器 ip 为: 10.219.24.23
os 环境为 :linux x86_64

参考连接: 为了节约劳动力,给出作者先前的完整连接,按照链接+下面的流程,即可搭建成功!
nginx之 nginx-1.9.7 编译安装、理论简介: http://blog.csdn.net/zhang123456456/article/details/73228668
tomcat之 JDK8.0安装、tomcat-8.5.15安装: http://blog.csdn.net/zhang123456456/article/details/73382524

1、 按照上面指定链接,完成 nginx 与 tomcat 安装后,接着进行下面的操作
2、 配置 webapps/ROOT/index.jsp 修改成如下所示
[root@mysql apache-tomcat-8.5.15]# pwd
/usr/local/tomcat/apache-tomcat-8.5.15
[root@mysql apache-tomcat-8.5.15]# vi webapps/ROOT/index.jsp
[root@mysql apache-tomcat-8.5.15]# cat webapps/ROOT/index.jsp
<html>
<h1>this is my tomcat1</h1>
</html>

说明: 同理配置另外一台 tomcat 服务器

3、 配置完 tomcat 后,接下来,修改 nginx.conf 配置,如下
[root@mysql03 nginx]# pwd
/usr/local/nginx
[root@mysql03 nginx]# cat conf/nginx.conf
user root root;
worker_processes 1;

events {
worker_connections 1024;
}

http {
include mime.types;
default_type application/octet-stream;

upstream web_app {
server 10.219.24.21:8080 weight=1 max_fails=2 fail_timeout=30s;
server 10.219.24.23:8080 weight=1 max_fails=2 fail_timeout=30s;
}

server {
listen 80;
server_name aa.com;
charset utf8;
location / {
proxy_next_upstream error timeout invalid_header http_500 http_502 http_503 http_504;
proxy_pass http://web_app;
proxy_redirect default;
}
}
}

说明: server段 proxy_pass定义的web_app需要跟upstream 里面定义的web_app一致,否则server找不到均衡。

4、 启动 tomcat 与 Nginx
5、 测试
本机浏览器输入:http://10.219.24.26/  反复点击刷新 发现链接在 tomcat1 与 tomcat2 之间轮转,达到负载均衡。

      

相关推荐
python开发_常用的python模块及安装方法
adodb:我们领导推荐的数据库连接组件bsddb3:BerkeleyDB的连接组件Cheetah-1.0:我比较喜欢这个版本的cheeta…
日期:2022-11-24 点赞:878 阅读:9,489
Educational Codeforces Round 11 C. Hard Process 二分
C. Hard Process题目连接:http://www.codeforces.com/contest/660/problem/CDes…
日期:2022-11-24 点赞:807 阅读:5,904
下载Ubuntn 17.04 内核源代码
zengkefu@server1:/usr/src$ uname -aLinux server1 4.10.0-19-generic #21…
日期:2022-11-24 点赞:569 阅读:6,737
可用Active Desktop Calendar V7.86 注册码序列号
可用Active Desktop Calendar V7.86 注册码序列号Name: www.greendown.cn Code: &nb…
日期:2022-11-24 点赞:733 阅读:6,490
Android调用系统相机、自定义相机、处理大图片
Android调用系统相机和自定义相机实例本博文主要是介绍了android上使用相机进行拍照并显示的两种方式,并且由于涉及到要把拍到的照片显…
日期:2022-11-24 点赞:512 阅读:8,128
Struts的使用
一、Struts2的获取  Struts的官方网站为:http://struts.apache.org/  下载完Struts2的jar包,…
日期:2022-11-24 点赞:671 阅读:5,291