欢迎来到尧图网

客户服务 关于我们

您的位置:首页 > 健康 > 养生 > Docker Compose 部署Nginx反向代理 tomcat

Docker Compose 部署Nginx反向代理 tomcat

2025/4/25 6:45:59 来源:https://blog.csdn.net/u013400314/article/details/146916551  浏览:    关键词:Docker Compose 部署Nginx反向代理 tomcat

Nginx 、Tomcat (默认端口8080)》》compose

services:nginx:image: nginx:latestcontainer_name: nginxrestart: alwaysports:- 80:80- 8080:8080volumes:# 文件夹会自动创建,但nginx.conf是文件,需要提前创建,否则 会自动创建nginx.conf文件夹- ./conf/nginx.conf:/etc/nginx/nginx.conf- ./html:/usr/share/nginx/htmltomcat1:image: tomcat:latestcontainer_name: tomcat1tomcate2:image: tomcat:latestcontainer_name: tomcat2

nginx的配置文件

worker_processes  2;events {worker_connections  1024;
}http {upstream httpd {server tomcat1:8080 weight=10;server tomcat2:8080 weight=10;}include       mime.types;default_type  application/octet-stream;sendfile        on;server {listen       80;#  为了模拟域名访问,  需要在访问的客户端 host 加   IP  service.zen.comserver_name  service.zen.com;#charset koi8-r;#access_log  logs/host.access.log  main;location / {proxy_pass http://httpd;}}}

在这里插入图片描述

运行 compose

#  运行 compose
docker compose up -d# 查看运行的容器进程
docker ps# 因tomcat 拉取 阿里云的, 阿里云是处理过的 ,保留核心的内容了
# 进入tomcat 容器
docker exec -it tomcat容器ID   /bin/bash
# 阿里云拉取的 tomcat   /usr/local/tomcat/webapps  是空的 阿里云把内容 存在 webapps.dist文件夹里了
cp -r  webapps.dist/* webapps/

在这里插入图片描述

在这里插入图片描述
在这里插入图片描述

版权声明:

本网仅为发布的内容提供存储空间,不对发表、转载的内容提供任何形式的保证。凡本网注明“来源:XXX网络”的作品,均转载自其它媒体,著作权归作者所有,商业转载请联系作者获得授权,非商业转载请注明出处。

我们尊重并感谢每一位作者,均已注明文章来源和作者。如因作品内容、版权或其它问题,请及时与我们联系,联系邮箱:809451989@qq.com,投稿邮箱:809451989@qq.com

热搜词