一、反向代理简介
反向代理(Reverse Proxy)方式是指以代理服务器来接受internet上的连接请求,然后将请求转发给内部网络上的服务器,并将从服务器上得到的结果返回给internet上请求连接的客户端,此时代理服务器对外就表现为一个反向代理服务器。
二、
1、Nginx和Tomcat环境信息
Nginx: ip:192.168.182.130 端口:80 安装位置:/usr/local/nginx
Tomcat1: ip:192.168.182.130 端口:8080 安装位置:/usr/local/tomcat/apache-tomcat-8.0.50/
Tomcat2:
ip:192.168.182.131 端口:8080 安装位置:/usr/local/tomcat/apache-tomcat-8.0.50/
2、为了便于测试,修改两个tomcat站点ROOT的index.jsp页面为
<%-- Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with this work for additional information regarding copyright ownership. The ASF licenses this file to You under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. --%> <%@ page pageEncoding="UTF-8" contentType="text/html; charset=UTF-8" %> <% java.text.SimpleDateFormat sdf = new java.text.SimpleDateFormat("yyyy"); request.setAttribute("year", sdf.format(new java.util.Date())); request.setAttribute("tomcatUrl", "http://tomcat.apache.org/"); request.setAttribute("tomcatDocUrl", "/docs/"); request.setAttribute("tomcatExamplesUrl", "/examples/"); %> <!DOCTYPE html> <html lang="en"> <h1>tomcat1</h1> SessionId:<%=session.getId()%><br/> SessionIP:<%=request.getServerName()%><br/> </html>