2023-10-17 19:48:45 +08:00
|
|
|
|
version: '3.9'
|
2023-11-01 21:26:54 +08:00
|
|
|
|
name: demo01-jib
|
2023-10-17 19:48:45 +08:00
|
|
|
|
services:
|
2023-10-29 19:48:16 +08:00
|
|
|
|
demo01-jib:
|
2023-10-30 10:07:50 +08:00
|
|
|
|
image: svn.youshengyun.com:9923/demo01-jib:1.0
|
2023-10-29 19:48:16 +08:00
|
|
|
|
container_name: demo01-jib
|
2023-11-01 21:26:54 +08:00
|
|
|
|
hostname: demo01-jib
|
2023-10-17 19:48:45 +08:00
|
|
|
|
restart: unless-stopped
|
|
|
|
|
extra_hosts:
|
|
|
|
|
- "host.docker.internal:host-gateway"
|
|
|
|
|
networks:
|
|
|
|
|
- y9-share-net
|
|
|
|
|
ports:
|
|
|
|
|
- "7055:7055"
|
2023-10-29 19:48:16 +08:00
|
|
|
|
environment:
|
2023-11-04 13:38:14 +08:00
|
|
|
|
server.port: 7055
|
|
|
|
|
server.servlet.context-path: '/demo01'
|
2023-10-27 13:36:45 +08:00
|
|
|
|
labels:
|
2023-11-04 13:38:14 +08:00
|
|
|
|
# 定义demo01-jib路由,entrypoints=web,接受http请求
|
2023-10-27 13:36:45 +08:00
|
|
|
|
- "traefik.enable=true"
|
2023-10-30 10:07:50 +08:00
|
|
|
|
- "traefik.http.routers.demo01-jib.entrypoints=web"
|
|
|
|
|
- "traefik.http.routers.demo01-jib.rule=PathPrefix(`/demo01`)"
|
2023-11-04 13:38:14 +08:00
|
|
|
|
|
|
|
|
|
# 定义demo01服务
|
|
|
|
|
- "traefik.http.services.demo01.loadbalancer.passHostHeader=true"
|
2023-11-01 21:26:54 +08:00
|
|
|
|
- "traefik.http.services.demo01.loadbalancer.server.port=7055"
|
|
|
|
|
|
2023-11-04 13:38:14 +08:00
|
|
|
|
# 指定路由demo01-jib的服务为demo01
|
|
|
|
|
- "traefik.http.routers.demo01-jib.service=demo01"
|
|
|
|
|
|
|
|
|
|
# 默认轮询的方式进行负载,session sticky放开下面的注释
|
|
|
|
|
#- "traefik.http.services.demo01.loadbalancer.sticky.cookie.name=demo01"
|
|
|
|
|
|
|
|
|
|
# 定义SSL,entrypoints=web-ssl,接受https请求,路由和服务要重新定义一次
|
2023-11-02 11:16:55 +08:00
|
|
|
|
- "traefik.http.routers.demo01-jib-ssl.tls=true"
|
2023-11-01 21:26:54 +08:00
|
|
|
|
- "traefik.http.routers.demo01-jib-ssl.entrypoints=web-ssl"
|
2023-11-05 20:55:30 +08:00
|
|
|
|
- "traefik.http.routers.demo01-jib-ssl.rule=Host(`www.dingzhaojun.top`) && PathPrefix(`/demo01`)"
|
2023-11-04 13:38:14 +08:00
|
|
|
|
- "traefik.http.routers.demo01-jib-ssl.service=demo01"
|
|
|
|
|
|
2023-11-05 20:55:30 +08:00
|
|
|
|
# 定义URL重定向中间件switch-domain,将http://localhost转换为https://www.dingzhaojun.top
|
2023-11-06 14:13:35 +08:00
|
|
|
|
- "traefik.http.middlewares.switch-domain.redirectregex.regex=^http://localhost:8081/demo01(.*)"
|
|
|
|
|
- "traefik.http.middlewares.switch-domain.redirectregex.replacement=https://www.dingzhaojun.top:7443/demo01$${1}"
|
2023-11-05 20:55:30 +08:00
|
|
|
|
|
|
|
|
|
# 定义URL中的scheme、port重定向中间件to-https,将http转换为https,8081转换为7443,但不转换IP地址部分
|
|
|
|
|
- "traefik.http.middlewares.to-https.redirectscheme.scheme=https"
|
|
|
|
|
- "traefik.http.middlewares.to-https.redirectscheme.permanent=true"
|
|
|
|
|
- "traefik.http.middlewares.to-https.redirectscheme.port=7443"
|
|
|
|
|
|
2023-11-06 14:13:35 +08:00
|
|
|
|
# 设置路由demo01-jib使用的中间件,switch-domain或者to-https二选一
|
|
|
|
|
# 也可以在compose-traefik.yml设置http跳转https,这样就不用在应用的docker里逐一设置了
|
|
|
|
|
#- "traefik.http.routers.demo01-jib.middlewares=switch-domain"
|
2023-10-17 19:48:45 +08:00
|
|
|
|
|
|
|
|
|
networks:
|
|
|
|
|
y9-share-net:
|
|
|
|
|
external: true
|