diff --git a/compose-demo01-jib.yml b/compose-demo01-jib.yml index 7c536c4..2e346a9 100644 --- a/compose-demo01-jib.yml +++ b/compose-demo01-jib.yml @@ -38,16 +38,17 @@ services: - "traefik.http.routers.demo01-jib-ssl.service=demo01" # 定义URL重定向中间件switch-domain,将http://localhost转换为https://www.dingzhaojun.top - - "traefik.http.middlewares.switch-domain.redirectregex.regex=^http://localhost(.*)" - - "traefik.http.middlewares.switch-domain.redirectregex.replacement=http://www.dingzhaojun.top$$1" + - "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}" # 定义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" - # 设置路由demo01-jib使用的中间件 - - "traefik.http.routers.demo01-jib.middlewares=switch-domain" + # 设置路由demo01-jib使用的中间件,switch-domain或者to-https二选一 + # 也可以在compose-traefik.yml设置http跳转https,这样就不用在应用的docker里逐一设置了 + #- "traefik.http.routers.demo01-jib.middlewares=switch-domain" networks: y9-share-net: diff --git a/compose-demo01-jvm.yml b/compose-demo01-jvm.yml index 9d8181d..0a10418 100644 --- a/compose-demo01-jvm.yml +++ b/compose-demo01-jvm.yml @@ -39,16 +39,17 @@ services: # 定义URL重定向中间件switch-domain,将http://localhost转换为https://www.dingzhaojun.top - - "traefik.http.middlewares.switch-domain.redirectregex.regex=^http://localhost(.*)" - - "traefik.http.middlewares.switch-domain.redirectregex.replacement=http://www.dingzhaojun.top$$1" + - "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}" # 定义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" - # 设置路由demo01-jib使用的中间件 - - "traefik.http.routers.demo01-jib.middlewares=switch-domain" + # 设置路由demo01-jib使用的中间件,switch-domain或者to-https二选一 + # 也可以在compose-traefik.yml设置http跳转https,这样就不用在应用的docker里逐一设置了 + #- "traefik.http.routers.demo01-jib.middlewares=switch-domain" networks: y9-share-net: diff --git a/compose-demo01-native.yml b/compose-demo01-native.yml index bb11f06..85e315d 100644 --- a/compose-demo01-native.yml +++ b/compose-demo01-native.yml @@ -38,16 +38,17 @@ services: - "traefik.http.routers.demo01-native-ssl.service=demo01" # 定义URL重定向中间件switch-domain,将http://localhost转换为https://www.dingzhaojun.top - - "traefik.http.middlewares.switch-domain.redirectregex.regex=^http://localhost(.*)" - - "traefik.http.middlewares.switch-domain.redirectregex.replacement=http://www.dingzhaojun.top$${1}" + - "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}" # 定义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" - # 设置路由demo01-jib使用的中间件 - - "traefik.http.routers.demo01-jib.middlewares=switch-domain" + # 设置路由demo01-jib使用的中间件,switch-domain或者to-https二选一 + # 也可以在compose-traefik.yml设置http跳转https,这样就不用在应用的docker里逐一设置了 + #- "traefik.http.routers.demo01-jib.middlewares=switch-domain" networks: y9-share-net: diff --git a/compose-traefik.yml b/compose-traefik.yml index 0852cba..262ac31 100644 --- a/compose-traefik.yml +++ b/compose-traefik.yml @@ -8,11 +8,11 @@ services: restart: unless-stopped extra_hosts: - "host.docker.internal:host-gateway" - - "www.dingzhaojun.top:127.0.0.1" + #- "www.dingzhaojun.top:127.0.0.1" networks: y9-share-net: {} - mynet: - ipv4_address: '192.168.31.250' + #mynet: + # ipv4_address: '192.168.31.250' ports: # Expose 8081 - "8081:8081" @@ -41,6 +41,8 @@ services: - "--entrypoints.web.address=:8081" - "--entrypoints.web-ssl.address=:7443" - "--entrypoints.traefik.address=:8080" + - "--entrypoints.web.http.redirections.entrypoint.to=web-ssl" + - "--entrypoints.web.http.redirections.entrypoint.scheme=https" - "--providers.docker=true" - "--providers.docker.watch=true" - "--providers.docker.exposedbydefault=false"