您的位置:首页 > 运维架构 > 反向代理

JAVAEE——宜立方商城14:项目部署规划、Tomcat热部署、反向代理的配置

2018-08-09 15:53 609 查看

1. 学习计划

1、系统部署

 

2. 项目部署

 

2.1. 项目架构讲解

 

 

 

2.2. 网络拓扑图

 

 

 

2.3. 系统部署

2.3.1. 部署分析

e3-manager

e3-manager-web

e3-portal-web

e3-content

e3-search

e3-search-web

e3-item-web

e3-sso

e3-sso-web

e3-cart-web

e3-order

e3-order-web

 

 

 

共需要48台服务器。

 

搭建伪分布式。

 

2.3.2. 服务器规划

 

 

2.3.3. 域名规划

序号

工程名

域名

1

e3-manager-web

manager.e3mall.cn

2

e3-portal-web

www.e3mall.cn

3

e3-search-web

search.e3mall.cn

4

e3-item-web

item.e3mall.cn

5

e3-sso-web

sso.e3mall.cn

6

e3-cart-web

cart.e3mall.cn

7

e3-order-web

order.e3mall.cn

 

 

2.3.4. Tomcat热部署

可以使用maven实现tomcat热部署。Tomcat启动时 部署工程。

Tomcat有个后台管理功能,可以实现工程热部署。

配置方法:

第一步:需要修改tomcat的conf/tomcat-users.xml配置文件。添加用户名、密码、权限。

<role rolename="manager-gui" />

<role rolename="manager-script" />

<user username="tomcat" password="tomcat" roles="manager-gui, manager-script"/>

第二步:重新启动tomcat。

 

使用maven的tomcat插件实现热部署:

第一步:配置tomcat插件,需要修改工程的pom文件。

 

<build>
<plugins>
<!-- 配置Tomcat插件 -->
<plugin>
<groupId>org.apache.tomcat.maven</groupId>
<artifactId>tomcat7-maven-plugin</artifactId>
<configuration>
<port>8081</port>
<path>/</path>
<url>http://192.168.25.135:8080/manager/text</url>
<username>tomcat</username>
<password>tomcat</password>
</configuration>
</plugin>
</plugins>
</build>

 

 

第二步:使用maven命令进行部署。
tomcat7:deploy

tomcat7:redeploy

部署的路径是“/”会把系统部署到webapps/ROOT目录下。

部署工程跳过测试:

clean tomcat7:redeploy -DskipTests

 

2.3.5. 工程部署

每个工程运行在不同的tomcat上,修改tomcat的端口号。

 

2.4. 反向代理的配置

测试时使用域名访问网站,需要修改host文件。

所有的域名应该指向反向代理服务器。

 

配置hosts文件:

192.168.25.141 manager.e3mall.cn

192.168.25.141 www.e3mall.cn

192.168.25.141 search.e3mall.cn

192.168.25.141 item.e3mall.cn

192.168.25.141 sso.e3mall.cn

192.168.25.141 cart.e3mall.cn

192.168.25.141 order.e3mall.cn

 

 

反向代理的配置:

#user  nobody;
worker_processes  1;

#error_log  logs/error.log;
#error_log  logs/error.log  notice;
#error_log  logs/error.log  info;

#pid        logs/nginx.pid;

events {
worker_connections  1024;
}

http {
include       mime.types;
default_type  application/octet-stream;

#log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
#                  '$status $body_bytes_sent "$http_referer" '
#                  '"$http_user_agent" "$http_x_forwarded_for"';

#access_log  logs/access.log  main;

sendfile        on;
#tcp_nopush     on;

#keepalive_timeout  0;
keepalive_timeout  65;

#gzip  on;

upstream manager.e3mall.cn {
server 192.168.25.137:8080;
}
upstream www.e3mall.cn {
server 192.168.25.137:8081;
}
upstream search.e3mall.cn {
server 192.168.25.137:8082;
}
upstream item.e3mall.cn {
server 192.168.25.138:8080;
}
upstream sso.e3mall.cn {
server 192.168.25.138:8081;
}
upstream cart.e3mall.cn {
server 192.168.25.139:8080;
}
upstream order.e3mall.cn {
server 192.168.25.139:8081;
}

server {
listen       80;
server_name  manager.e3mall.cn;

#charset koi8-r;

#access_log  logs/host.access.log  main;

location / {
proxy_pass   http://manager.e3mall.cn;
index  index.html index.htm;
}
}
server {
listen       80;
server_name  www.e3mall.cn;

#charset koi8-r;

#access_log  logs/host.access.log  main;

location / {
proxy_pass   http://www.e3mall.cn;
index  index.html index.htm;
}
}
server {
listen       80;
server_name  search.e3mall.cn;

#charset koi8-r;

#access_log  logs/host.access.log  main;

location / {
proxy_pass   http://search.e3mall.cn;
index  index.html index.htm;
}
}
server {
listen       80;
server_name  item.e3mall.cn;

#charset koi8-r;

#access_log  logs/host.access.log  main;

location / {
proxy_pass   http://item.e3mall.cn;
index  index.html index.htm;
}
}
server {
listen       80;
server_name  sso.e3mall.cn;

#charset koi8-r;

#access_log  logs/host.access.log  main;

location / {
proxy_pass   http://sso.e3mall.cn;
index  index.html index.htm;
}
}
server {
listen       80;
server_name  cart.e3mall.cn;

#charset koi8-r;

#access_log  logs/host.access.log  main;

location / {
proxy_pass   http://cart.e3mall.cn;
index  index.html index.htm;
}
}
server {
listen       80;
server_name  order.e3mall.cn;

#charset koi8-r;

#access_log  logs/host.access.log  main;

location / {
proxy_pass   http://order.e3mall.cn;
index  index.html index.htm;
}
}

}

 

内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐