nginx:192.168.2.110
tomcat:
node120:192.168.2.120
node121:192.168.2.121
-->tomcat node120配置:
tomcat 服务配置:
vim server.xml
.......
<Engine name="Catalina" defaultHost="node120">
.....
</Host>
<Host name="node120" appBase="/data/webapps" autoDeploy="true">
<Context path="" docBase="ROOT" />
<Valve className="org.apache.catalina.valves.AccessLogValve" directory="/data/webapps/logs"
prefix="node120_access_log" suffix=".txt"
pattern="%h %l %u %t "%r" %s %b" />
</Host>
</Engine>
</Service>
</Server>
网站目录文件:
[root@node120 webapps]# pwd
/data/webapps
[root@node120 webapps]# tree
.
|-- ROOT
| |-- META-INF
| |-- WEB-INF
| |-- classes
| |-- index.jsp
| |-- lib
| `-- root
`-- logs
`-- node120_access_log.2017-05-07.txt
6 directories, 3 files
网站目录index.jps文件:
[root@node120 ROOT]# cat index.jsp
<%@ page language="java" %>
<%@ page import="java.util.*" %>
<html>
<head>
<title>JSP Test Page node120</title>
</head>
<body>
<% out.println("Hello,World node120"); %>
</body>
</html>
重启tomcat服务:
service tomcat restart
网页访问:http://192.168.2.120:8080
-->tomcat node121配置:
tomcat 服务配置:
vim server.xml
.......
<Engine name="Catalina" defaultHost="node121">
.....
</Host>
<Host name="node121" appBase="/data/webapps" autoDeploy="true">
<Context path="" docBase="ROOT" />
<Valve className="org.apache.catalina.valves.AccessLogValve" directory="/data/webapps/logs"
prefix="node121_access_log" suffix=".txt"
pattern="%h %l %u %t "%r" %s %b" />
</Host>
</Engine>
</Service>
</Server>
网站目录文件:
[root@node121 webapps]# pwd
/data/webapps
[root@node121 webapps]# tree
.
|-- ROOT
| |-- META-INF
| |-- WEB-INF
| |-- classes
| |-- index.jsp
| |-- lib
| `-- root
`-- logs
`-- node121_access_log.2017-05-07.txt
6 directories, 3 files
网站目录index.jps文件:
[root@node121 ROOT]# cat index.jsp
<%@ page language="java" %>
<%@ page import="java.util.*" %>
<html>
<head>
<title>JSP Test Page node121</title>
</head>
<body>
<% out.println("Hello,World node121"); %>
</body>
</html>
重启tomcat服务:
service tomcat restart
网页访问:http://192.168.2.121:8080
Nginx反向代理配置:192.168.2.110
在nginx主文件中包含负载均衡配置文件:
cat nginx.conf
include extra/upstream_tomcat.conf;
[root@node110 extra]# pwd
/usr/local/nginx-1.6.2/conf/extra
[root@node110 extra]# cat upstream_tomcat.conf
upstream tomcat_servers {
server 192.168.2.120:8080 weight=10;
server 192.168.2.121:8080 weight=10;
}
server {
listen 80;
server_name tomcat.linuxmysql.com;
location / {
proxy_pass http://tomcat_servers;
}
}
客户端访问:
http://tomcat.linuxmysql.com
2017-05-07
nginx反向代理后端两台tomcat服务器
评论
发表评论
姓 名: