Nginx+Tomcat动静分离
在tomcat1和tomcat2的webapp下创建ngnix文件夹,在ngnix下创建img文件夹和index.jsp
在tomcat1和tomcat2分别的/webapp/nginx下分别创建:index.jsp
<%@ page import="java.util.Date" %>
<%@ page import="java.text.SimpleDateFormat" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
<title>Title</title>
</head>
<body>
<%
Date date = new Date();
SimpleDateFormat sdf = new SimpleDateFormat("yyy-MM-dd hh:mm:ss");
String d = sdf.format(date);
out.print(d);
%>
<img src="/nginx/img/1.jpg">
</body>
</html>
访问:linux虚拟机的地址/nginx
例如:
192.168.232.98/nginx
这就实现了Nginx + Tomcat 的动态分离
实现的前提是需要部署tomcat集群:安装配置好tomcat1和tomcat2,以及nginx的安装配置