tomcat多级反向代理

88 阅读1分钟

tomcat 介绍

Tomcat 服务器是一个免费的开放源代码的Web 应用服务器,属于轻量级应用服务器,在中小型系统和

并发访问用户不是很多的场合下被普遍使用,Tomcat 具有处理HTML页面的功能,它还是一个Servlet和JSP容器 Tomcat 服务器是一个免费的开放源代码的Web 应用服务器,属于轻量级应用服务器,在中小型系统和

并发访问用户不是很多的场合下被普遍使用,Tomcat 具有处理HTML页面的功能,它还是一个Servlet和JSP容器

tomcat多级反向代理

image.png

192.168.10.1 代理服务器配置

注意 upstream web 配置在http下 location /配置在server下

systemctl stop firewalld
setenforce 0
yum install  epel-release.noarch -y
yum install  nginx -y
systemctl  start  nginx
vim  /etc/nginx/nginx.conf

  upstream  web {
    server 192.168.91.101;
    server 192.168.91.102;

   }

location  / {
        proxy_pass  http://web/;

}

nginx  -s reload

image.png

192.168.10.0 nginx配置


systemctl stop firewalld
setenforce 0
yum install  epel-release.noarch -y
yum install  nginx -y
systemctl  start  nginx

vim  /etc/nginx/nginx.conf

 location ~  \.(jpg|html|png|css)$ {
        root         /usr/share/nginx/html;
         }
        location ~  \.jsp$ {
         proxy_pass http://192.168.10.30:8080;
         }

echo  7-2  > /usr/share/nginx/html/index.html

image.png

192.168.10.20 nginx 代理服务器

systemctl stop firewalld
setenforce 0
yum install  epel-release.noarch -y
yum install  nginx -y
systemctl  start  nginx

vim  /etc/nginx/nginx.conf

 location ~  \.(jpg|html|png|css)$ {
        root         /usr/share/nginx/html;
         }
        location ~  \.jsp$ {
         proxy_pass http://192.168.10.40:8080;
         }

echo  7-3  > /usr/share/nginx/html/index.html

安装tomcat echo 7-4 > /usr/local/tomcat/webapps/ROOT/test.jsp

echo 7-5 > /usr/local/tomcat/webapps/ROOT/test.jp

当请求为静态页面时 7-2 和7-3 处理请求,当请求为jsp结尾时候,则交给tomcat服务器处理

image.png

image.png