Docker

Docker容器部署Apache+Tomcat动静分离

2019-01-06  本文已影响38人  iXiAo9

环境:

Centos:7.5

Docker版本:18.09.0

服务器IP: 192.168.189.128

创建httpd容器

docker run --name httpd -d -p 80:80 -v /opt/html/:/var/www/html 10.30.12.55/docker/httpd-jk

创建tomcat容器

docker run --name tomcat -d -p 8009:8009 -v /opt/html:/usr/local/tomcat/webapps 10.30.12.55/docker/tomcat

修改httpd容器jk的配置文件,配置后端tocmat的ip地址

进入到容器中

docker exec -it httpd /bin/bash

编辑workers配置文件

vi /etc/httpd/conf/workers

worker.list=wlb

#
# Defining a worker named ajp13w and of type ajp13
# Note that the name and the type do not have to match.
#
worker.tomcat1.type=ajp13
worker.tomcat1.host=192.168.189.128
worker.tomcat1.port=8009

#
# Defining a load balancer
#

worker.wlb.type=lb
worker.wlb.balance_workers=tomcat1

上传solo.war项目到/opt/html共享目录中

tomcat会自动解压solo.war包

修改solo配置文件,配置访问url地址

vim /opt/html/solo/WEB-INF/classes/latke.properties

修改内容如下,配置访问的协议、ip和端口

#### Server ####
# Browser visit protocol
serverScheme=http
# Browser visit domain name
serverHost=192.168.189.128
# Browser visit port, 80 as usual, THIS IS NOT SERVER LISTEN PORT!
serverPort=80

重启Tomcat容器

docker restart tomcat

访问httpd容器

http://192.168.189.128/solo

<footer style="color: rgb(85, 85, 85); font-family: Lato, "PingFang SC", "Microsoft YaHei", sans-serif; font-size: 14px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: rgb(255, 255, 255); text-decoration-style: initial; text-decoration-color: initial;">

动静分离

</footer>

上一篇 下一篇

猜你喜欢

热点阅读