当前位置: 首页 > news >正文

nginx反向代理tomcat多实例

1.tomcat多实例配置_基于端口号
前期需要准备java 环境 这里不作赘述

# 下载tomcat源码包
# 清华站点下载
https://mirrors.tuna.tsinghua.edu.cn/apache/tomcat/tomcat-8/v8.5.95/bin/apache-tomcat-8.5.95.tar.gz
https://mirrors.tuna.tsinghua.edu.cn/apache/tomcat/tomcat-9/v9.0.82/bin/apache-tomcat-9.0.82.tar.gz
https://mirrors.tuna.tsinghua.edu.cn/apache/tomcat/tomcat-10/v10.1.15/bin/apache-tomcat-10.1.15.tar.gz[root@localhost tar]# tar xf apache-tomcat-8.5.96.tar.gz 
[root@localhost tar]# ls
apache-tomcat-10.1.24.tar.gz  apache-tomcat-8.5.96.tar.gz       jdk-8u251-linux-x64.tar.gz  jvmtop-0.8.0.tar.gz
apache-tomcat-8.5.96          jdk-11.0.23_linux-x64_bin.tar.gz  jpress-web-newest.war       visualvm_202.zip[root@localhost tar]# cp -a apache-tomcat-8.5.96 /usr/local/tomcat8.5_01
[root@localhost tar]# cp -a apache-tomcat-8.5.96 /usr/local/tomcat8.5_02[root@localhost tar]# ll /usr/local/ | grep tomcat
drwxr-xr-x. 9 root root 220 923 11:39 tomcat8.5_01
drwxr-xr-x. 9 root root 220 923 11:39 tomcat8.5_02[root@localhost tar]# sed -i 's#8005#8011#;s#8080#8081#' /usr/local/tomcat8.5_01/conf/server.xml
[root@localhost tar]# sed -i 's#8005#8012#;s#8080#8082#' /usr/local/tomcat8.5_02/conf/server.xml[root@localhost tar]# /usr/local/tomcat8.5_01/bin/startup.sh 
[root@localhost tar]# /usr/local/tomcat8.5_02/bin/startup.sh[root@localhost tar]# ss -tuln | grep 80                                         
tcp    LISTEN     0      100      :::8081                 :::*                  
tcp    LISTEN     0      100      :::8082                 :::*  

2.nginx 反向代理tomcat

# 安装
[root@localhost tar]# yum -y install nginx[root@localhost tar]# systemctl start nginx[root@localhost tar]# netstat -lntup | grep nginx
tcp        0      0 0.0.0.0:80              0.0.0.0:*               LISTEN      29873/nginx: master 
tcp6       0      0 :::80                   :::*                    LISTEN      29873/nginx: master [root@localhost tar]# vim /etc/nginx/conf.d/tomcat.conf upstream tomcatWeb {server 192.168.29.200:8081;server 192.168.29.200:8082;}server {listen       80;server_name  192.168.29.200;location / {proxy_pass http://tomcatWeb;}error_page   500 502 503 504  /50x.html;location = /50x.html {root   html;}}[root@localhost tar]# echo 8081 > /usr/local/tomcat8.5_01/webapps/ROOT/index.jsp 
[root@localhost tar]# echo 8082 > /usr/local/tomcat8.5_02/webapps/ROOT/index.jsp
[root@localhost tar]# nginx -t
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful
[root@localhost tar]# systemctl restart nginx[root@localhost tar]# curl 192.168.29.200
8081
[root@localhost tar]# curl 192.168.29.200
8081
[root@localhost tar]# curl 192.168.29.200
8082
[root@localhost tar]# curl 192.168.29.200
8082
[root@localhost tar]# curl 192.168.29.200
8081

http://www.mrgr.cn/news/34158.html

相关文章:

  • 云盘还安全么?阿里云盘出现BUG,惊现大量陌生人照片
  • FreeRTOS下UART的封装
  • 基于DeepFace深度学习模型的离线版人脸识别API接口实现(类似百度在线API接口)
  • 3dmax选择全解:高效建模的关键技巧
  • Dockerfile全面指南:从基础到进阶,掌握容器化构建的核心工具
  • PyCharm远程源代码缓存与代码补全功能
  • PMP考试考前需要做什么才能提高上岸率?
  • 来!一起探索 2024 年数据和 AI 的奇妙世界
  • 策略模式与工厂模式的区别
  • Axios 封装网络请求
  • 【教学类-52-11】20240919动物数独(4宫格)1图、2图、6图、有答案、无答案 组合版18套
  • 外包干了4年,技术退步太明显了。。。。。
  • 防火墙详解(一) 网络防火墙简介
  • 导致mfc140u.dll,无法继续执行代码的原因分析及解决方法
  • 数据安全治理
  • 华为防火墙配置双机热备
  • netstat 命令:网络监控
  • 发票查验API接口是什么?发票查验接口用python demo示例如何集成
  • hCaptcha 图像识别 API 对接说明
  • 【Go】Go语言切片(Slice)深度剖析与应用实战