This commit is contained in:
dzj 2023-11-06 14:13:35 +08:00
parent 5eba3bd9a6
commit 21d10e8cf4
4 changed files with 20 additions and 15 deletions

View File

@ -38,16 +38,17 @@ services:
- "traefik.http.routers.demo01-jib-ssl.service=demo01" - "traefik.http.routers.demo01-jib-ssl.service=demo01"
# 定义URL重定向中间件switch-domain将http://localhost转换为https://www.dingzhaojun.top # 定义URL重定向中间件switch-domain将http://localhost转换为https://www.dingzhaojun.top
- "traefik.http.middlewares.switch-domain.redirectregex.regex=^http://localhost(.*)" - "traefik.http.middlewares.switch-domain.redirectregex.regex=^http://localhost:8081/demo01(.*)"
- "traefik.http.middlewares.switch-domain.redirectregex.replacement=http://www.dingzhaojun.top$$1" - "traefik.http.middlewares.switch-domain.redirectregex.replacement=https://www.dingzhaojun.top:7443/demo01$${1}"
# 定义URL中的scheme、port重定向中间件to-https将http转换为https8081转换为7443但不转换IP地址部分 # 定义URL中的scheme、port重定向中间件to-https将http转换为https8081转换为7443但不转换IP地址部分
- "traefik.http.middlewares.to-https.redirectscheme.scheme=https" - "traefik.http.middlewares.to-https.redirectscheme.scheme=https"
- "traefik.http.middlewares.to-https.redirectscheme.permanent=true" - "traefik.http.middlewares.to-https.redirectscheme.permanent=true"
- "traefik.http.middlewares.to-https.redirectscheme.port=7443" - "traefik.http.middlewares.to-https.redirectscheme.port=7443"
# 设置路由demo01-jib使用的中间件 # 设置路由demo01-jib使用的中间件switch-domain或者to-https二选一
- "traefik.http.routers.demo01-jib.middlewares=switch-domain" # 也可以在compose-traefik.yml设置http跳转https这样就不用在应用的docker里逐一设置了
#- "traefik.http.routers.demo01-jib.middlewares=switch-domain"
networks: networks:
y9-share-net: y9-share-net:

View File

@ -39,16 +39,17 @@ services:
# 定义URL重定向中间件switch-domain将http://localhost转换为https://www.dingzhaojun.top # 定义URL重定向中间件switch-domain将http://localhost转换为https://www.dingzhaojun.top
- "traefik.http.middlewares.switch-domain.redirectregex.regex=^http://localhost(.*)" - "traefik.http.middlewares.switch-domain.redirectregex.regex=^http://localhost:8081/demo01(.*)"
- "traefik.http.middlewares.switch-domain.redirectregex.replacement=http://www.dingzhaojun.top$$1" - "traefik.http.middlewares.switch-domain.redirectregex.replacement=https://www.dingzhaojun.top:7443/demo01$${1}"
# 定义URL中的scheme、port重定向中间件to-https将http转换为https8081转换为7443但不转换IP地址部分 # 定义URL中的scheme、port重定向中间件to-https将http转换为https8081转换为7443但不转换IP地址部分
- "traefik.http.middlewares.to-https.redirectscheme.scheme=https" - "traefik.http.middlewares.to-https.redirectscheme.scheme=https"
- "traefik.http.middlewares.to-https.redirectscheme.permanent=true" - "traefik.http.middlewares.to-https.redirectscheme.permanent=true"
- "traefik.http.middlewares.to-https.redirectscheme.port=7443" - "traefik.http.middlewares.to-https.redirectscheme.port=7443"
# 设置路由demo01-jib使用的中间件 # 设置路由demo01-jib使用的中间件switch-domain或者to-https二选一
- "traefik.http.routers.demo01-jib.middlewares=switch-domain" # 也可以在compose-traefik.yml设置http跳转https这样就不用在应用的docker里逐一设置了
#- "traefik.http.routers.demo01-jib.middlewares=switch-domain"
networks: networks:
y9-share-net: y9-share-net:

View File

@ -38,16 +38,17 @@ services:
- "traefik.http.routers.demo01-native-ssl.service=demo01" - "traefik.http.routers.demo01-native-ssl.service=demo01"
# 定义URL重定向中间件switch-domain将http://localhost转换为https://www.dingzhaojun.top # 定义URL重定向中间件switch-domain将http://localhost转换为https://www.dingzhaojun.top
- "traefik.http.middlewares.switch-domain.redirectregex.regex=^http://localhost(.*)" - "traefik.http.middlewares.switch-domain.redirectregex.regex=^http://localhost:8081/demo01(.*)"
- "traefik.http.middlewares.switch-domain.redirectregex.replacement=http://www.dingzhaojun.top$${1}" - "traefik.http.middlewares.switch-domain.redirectregex.replacement=https://www.dingzhaojun.top:7443/demo01$${1}"
# 定义URL中的scheme、port重定向中间件to-https将http转换为https8081转换为7443但不转换IP地址部分 # 定义URL中的scheme、port重定向中间件to-https将http转换为https8081转换为7443但不转换IP地址部分
- "traefik.http.middlewares.to-https.redirectscheme.scheme=https" - "traefik.http.middlewares.to-https.redirectscheme.scheme=https"
- "traefik.http.middlewares.to-https.redirectscheme.permanent=true" - "traefik.http.middlewares.to-https.redirectscheme.permanent=true"
- "traefik.http.middlewares.to-https.redirectscheme.port=7443" - "traefik.http.middlewares.to-https.redirectscheme.port=7443"
# 设置路由demo01-jib使用的中间件 # 设置路由demo01-jib使用的中间件switch-domain或者to-https二选一
- "traefik.http.routers.demo01-jib.middlewares=switch-domain" # 也可以在compose-traefik.yml设置http跳转https这样就不用在应用的docker里逐一设置了
#- "traefik.http.routers.demo01-jib.middlewares=switch-domain"
networks: networks:
y9-share-net: y9-share-net:

View File

@ -8,11 +8,11 @@ services:
restart: unless-stopped restart: unless-stopped
extra_hosts: extra_hosts:
- "host.docker.internal:host-gateway" - "host.docker.internal:host-gateway"
- "www.dingzhaojun.top:127.0.0.1" #- "www.dingzhaojun.top:127.0.0.1"
networks: networks:
y9-share-net: {} y9-share-net: {}
mynet: #mynet:
ipv4_address: '192.168.31.250' # ipv4_address: '192.168.31.250'
ports: ports:
# Expose 8081 # Expose 8081
- "8081:8081" - "8081:8081"
@ -41,6 +41,8 @@ services:
- "--entrypoints.web.address=:8081" - "--entrypoints.web.address=:8081"
- "--entrypoints.web-ssl.address=:7443" - "--entrypoints.web-ssl.address=:7443"
- "--entrypoints.traefik.address=:8080" - "--entrypoints.traefik.address=:8080"
- "--entrypoints.web.http.redirections.entrypoint.to=web-ssl"
- "--entrypoints.web.http.redirections.entrypoint.scheme=https"
- "--providers.docker=true" - "--providers.docker=true"
- "--providers.docker.watch=true" - "--providers.docker.watch=true"
- "--providers.docker.exposedbydefault=false" - "--providers.docker.exposedbydefault=false"