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>
若有两个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>
tomcat 反代配置的更多相关文章
- nginx多层反代配置变量proxy_set_header
Nginx多层反代配置变量proxy_set_header过程记录 第一层代理: (1)路径: $ vim /data/soft/nginx/conf/vhost/xixi.conf (2)内容:(注 ...
- nginx负载均衡(5种方式)、rewrite重写规则及多server反代配置梳理
Nginx除了可以用作web服务器外,他还可以用来做高性能的反向代理服务器,它能提供稳定高效的负载均衡解决方案.nginx可以用轮询.IP哈希.URL哈希等方式调度后端服务器,同时也能提供健康检查功能 ...
- (转)nginx负载均衡(5种方式)、rewrite重写规则及多server反代配置梳理
Nginx除了可以用作web服务器外,他还可以用来做高性能的反向代理服务器,它能提供稳定高效的负载均衡解决方案.nginx可以用轮询.IP哈希.URL哈希等方式调度后端服务器,同时也能提供健康检查功能 ...
- nginx反代及后端web配置
一.反代配置,proxy_pass指向的upstream需要在反代的nginx.conf中配置 server {access_log /home/nginx/front_access.log;erro ...
- Nginx/Httpd反代tomcat配置
在上一篇博客中,我们了解了tomcat的server.xml中各组件的用法和作用:其中对于tomcat连接器来说,它分三类,一类是http连接器,一类是https连接器,一类是ajp连接器:通常tom ...
- Nginx反代服务器进阶学习最佳配置实践指南
转载自:https://www.bilibili.com/read/cv16150010?spm_id_from=333.999.0.0 0x00 编译实践 描述:在企业线上生产环境中推荐进行Ngin ...
- Nginx反代服务器基础配置实践案例
转载自:https://www.bilibili.com/read/cv16149433?spm_id_from=333.999.0.0 方式1: 轮询 RR(默认轮询)每个请求按时间顺序逐一分配到不 ...
- Centos7-yum部署配置LAMP-之LAMP及php-fpm实现反代动态资源
一.简介 LAMP:linux+apache+mysql(这里用mariadb)+php(perl,python) LAMMP:memcached缓存的 CGI:Common Gateway Inte ...
- tomcat 的优化配置
一.关于并发连接量的配置 在tomcat的server.xml配置文件中:将<Connector port="8080" protocol="HTTP/1.1&qu ...
随机推荐
- springcloud-4:服务注册(hello-service)
服务端 请见 http://www.cnblogs.com/huiy/p/8668005.html 客户端: 主启动类 import org.springframework.boot.SpringAp ...
- lanmp安装
下载安装(ssh登录服务器,执行如下操作即可,需要用到root用户权限来安装)源码编译安装wget http://dl.wdlinux.cn:5180/lanmp_laster.tar.gztar z ...
- 【原创】大数据基础之Presto(1)简介、安装、使用
presto 0.217 官方:http://prestodb.github.io/ 一 简介 Presto is an open source distributed SQL query engin ...
- Jmeter之csv参数化
创建数据源csv文件 在线程组中添加CSV Data Set Config 1.添加CSV Data Set Config 添加CSV Data Set Config 2.配置CSV Data Set ...
- Eleaticsearch源码分析(一)编译启动
转自:https://lunatictwo.github.io/2017/12/21/Eleaticsearch%E6%BA%90%E7%A0%81%E5%88%86%E6%9E%90(%E4%B8% ...
- 一个简单的Loading控件
实现效果如下: 使用方法: 在layout文件中添加以下代码: <com.example.jack.ui.widget.RingLoading android:layout_width=&quo ...
- swift 实践- 02 -- 自定义cell 的简单使用
import UIKit class MyTableViewCell: UITableViewCell { var imageV: UIImageView? var titleLabel: UILab ...
- verilog-产生axis数据流
首先这是产生aixs数据流的代码 `timescale 1ps/1ps `default_nettype none module axis_switch_0_example_master #( ) ( ...
- Maven设置本地仓库路径
在maven文件下的settings.xml中添加<localRepository>F:\cppdy\repo</localRepository>(本地仓库路径)
- MYSQL之 error while loading shared libraries: libtinfo.so.5: cannot open shared objectfile: No such f
环境:ubuntu18 登陆MYSQL时遇到错误:mysql: error while loading shared libraries: libtinfo.so.5: cannot open sha ...