日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

tomcat 反代配置

發布時間:2024/10/12 编程问答 24 豆豆
生活随笔 收集整理的這篇文章主要介紹了 tomcat 反代配置 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

tomcat反代可以基于nginx , http進行反代

反代服務器: 有兩個網口? 反代服務器一般有兩塊網卡一塊處于外網,一塊處于內網用于與后端服務器通信

tomcat 節點處于內網地址

1 tomcat安裝

  1 安裝jdk等軟件包

yum? install? java-1.8.0-openjdk-devel?? tomcat? tomcat-webapps? tomcat-admin-webapps? tomcat-docs-webapp??? -y

?2 啟動服務:systemctl?? start? tomcat.service

tomcat安裝完成

nginx反代服務器:

1 安裝nginx

yum? install? nginx?? -y

2 配置配置文件 ,在conf.d下配置個虛擬機,通過虛擬機進行反代

vim?? ilinux.conf

server? {

????? listen? 80;

????? server? name? www.ilinux.io;

????? location? /? {

?????????? proxy_pass?? http://192.168.10.11:8080;

????? }

}

nginx? -t? ? 檢查語法

啟動nginx服務:

?systemctl?? start? nginx.service??

訪問:www.ilinux.io???? 訪問之前在/etc/hosts 下做域名解析

如這里給tomcat一個test測試頁

mkdir?? -pv? /var/lib/tomcat/webapps/test/{WEB-INF,META-INF,classes,lib}

創建主頁面

: vim /var/lib/tomcat/webapps/test/index.jsp

<%@ page language="java" %>

<html>

????? <head><title>TomcatA</title></head>

????? <body>

?????????? <h1><font color="red">TomcatA.magedu.com</font></h1>

?????????? <table align="centre" border="1">

???????????????? <tr>

????????????????????? <td>Session ID</td>

???????????????? <% session.setAttribute("magedu.com","magedu.com"); %>

????????????? ????? <td><%= session.getId() %></td>

????? ?????????? </tr>

???????????????? <tr>

????????????????????? <td>Created on</td>

?????????? ???? ????????? <td><%= session.getCreationTime() %></td>

???????????????? </tr>

?????????? </table>

????? </body>

</html>

訪問:www.ilinux.io/test

若有兩個tomcat也可以實現動靜分離

location??? /?? {

?????????? proxy_pass? http://192.168.1.15:80;

????? }

????? location? ~* \.{jsp|do}$?? {

?????????? proxy_pass http://192.168.10.11:8080;

????? }

?

使用http實現反代

? ? ? yum install?? httpd??? -y

http做反代有兩種模式

一種是httpd協議? 一種jsp協議

# httpd?? -M?? 查看模塊的

其中:

proxy _module? {shared}??? 是主模塊起反代功能的必須啟用

proxy_http_module {shared}?? 基于httpd協議進行反代的

proxy_ajp_module (shared)?? 基于ajp協議進行反代的

配置文件設置

vim?? conf.d/ilinux-tomcat.conf

<VirutalHost? *:80>

????? ServerName??? www.ilinux.io

????? DocumentRoot? “/data/ilinux/htdocs”

????? ProxyRequests Off??????????????????????? 禁止正向代理

????? ProxyPreserveHost On???????????????? 是否把響應報文的host首部一并轉到后端

????? ProxyVia??? on

????? <Proxy *>??? ????????????? 定那些用戶訪問權限的

????? Require all granted

????? </Proxy>

????? ProxyPass / http://tc1.magedu.com:8080/??????????????? 把根 反代到那

????? ProxyPassReverse / http://tc1.magedu.com:8080/ ????????? 若后端有重定向

????? <Location />?????? ?????????? 定義基于根的訪問權限

????? Require all granted

????? </Location>

</VirutalHost>

httpd? -t? 測試語法

啟動服務

訪問: wwwilinux.io/

2 基于proxy_ajp_module模塊代理配置示例:

<VirtualHost *:80>

? ?   ServerName????? tc1.magedu.com

   ProxyRequests Off

   ProxyVia??????? On

   roxyPreserveHost On

   <Proxy *>

????? ?????   Require all granted

   </Proxy>

   ProxyPass / ajp://tc1.magedu.com:8009/

   ProxyPassReverse / ajp://tc1.magedu.com:8009/

   <Location />

?     Require all granted

   </Location>

</VirtualHost>

?

轉載于:https://www.cnblogs.com/huxl1/p/9538127.html

總結

以上是生活随笔為你收集整理的tomcat 反代配置的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。