Hi,
I'm running 2 instances of traefik inside a docker swarm cluster.
My goal is that service square will talk to traefik1 in http, traefik1 will transfer the message to traefik2 in https, and then traefik2 will terminate the TLS, and transmit the request to the endpoint service in http.
When I'm using it with http, everything works as expected, but when I'm using TLS with my self-signed certificate, I get 302 when trying to access service triangle from service square.
My configurations:
docker compose file:
version: '3.7'
services:
triangle:
image: testwebapp:1.0.0
deploy:
labels:
- traefik.enable=true
- traefik.docker.network=test_net
- traefik.docker.lbswarm=true
- traefik.http.routers.internal-router-triangle-in.rule=PathPrefix(`/triangle`)
- traefik.http.middlewares.stripprefix-triangle.stripprefix.prefixes=/triangle
- traefik.http.routers.internal-router-triangle-in.middlewares=stripprefix-triangle@docker
- traefik.http.services.nano_server1.loadbalancer.server.port=80
- traefik.http.routers.internal-router-triangle-in.entrypoints=internal_https2
- traefik.http.routers.internal-router-triangle-in.tls=true
- traefik.instance=traefik2
placement:
constraints: [node.hostname == DockerSwarm3]
networks:
- test_net
square:
image: testwebapp:1.0.0
deploy:
labels:
- traefik.enable=true
- traefik.docker.network=test_net
- traefik.docker.lbswarm=true
- traefik.http.routers.internal-router-square-in.rule=PathPrefix(`/square`)
- traefik.http.middlewares.stripprefix-square.stripprefix.prefixes=/square
- traefik.http.routers.internal-router-square-in.middlewares=stripprefix-square@docker
- traefik.http.services.nano_server3.loadbalancer.server.port=80
- traefik.http.routers.internal-router-square-in.entrypoints=internal_https1
- traefik.http.routers.internal-router-square-in.tls=true
- traefik.instance=traefik1
placement:
constraints: [node.hostname == DockerSwarm2]
networks:
- test_net
traefik1:
image: traefik:2.0.0-windowsservercore-1809
command:
- "--log.level=DEBUG"
- "--log.filepath=log/traefik.log"
- "--global.checkNewVersion=true"
- "--global.sendAnonymousUsage=true"
- "--entrypoints.internal1.address=:90"
- "--entrypoints.internal_https1.address=:443"
- "--providers.docker.swarmmode=true"
- "--providers.docker.exposedbydefault=false"
- "--providers.docker.watch=true"
- "--providers.docker.endpoint=npipe:////./pipe/docker_engine"
- "--api"
- "--api.insecure=true"
- "--providers.docker.constraints=Label(`traefik.instance`, `traefik1`)"
- "--providers.file.filename=config.toml"
- "--serverstransport.insecureskipverify=true"
ports:
- 8080:8080
networks:
- test_net
volumes:
- source: '\\.\pipe\docker_engine'
target: '\\.\pipe\docker_engine'
type: npipe
- 'C:\Users\Administrator\Desktop\SelfSignedCertificate:C:\keys\'
- 'C:\Users\Administrator\Desktop\traefik\configfile:C:\etc\traefik\'
placement:
constraints: [node.hostname == DockerSwarm2]
traefik2:
image: traefik:2.0.0-windowsservercore-1809
command:
- "--log.level=DEBUG"
- "--log.filepath=log/traefik.log"
- "--global.checkNewVersion=true"
- "--global.sendAnonymousUsage=true"
- "--entrypoints.internal2.address=:90"
- "--entrypoints.internal_https2.address=:443"
- "--providers.docker.swarmmode=true"
- "--providers.docker.exposedbydefault=false"
- "--providers.docker.watch=true"
- "--providers.docker.endpoint=npipe:////./pipe/docker_engine"
- "--api"
- "--api.insecure=true"
- "--providers.docker.constraints=Label(`traefik.instance`, `traefik2`)"
- "--providers.file.filename=config.toml"
- "--serverstransport.insecureskipverify=true"
ports:
- 8081:8080
networks:
- test_net
volumes:
- source: '\\.\pipe\docker_engine'
target: '\\.\pipe\docker_engine'
type: npipe
- 'C:\Users\Administrator\Desktop\SelfSignedCertificate:C:\keys\'
- 'C:\Users\Administrator\Desktop\traefik\configfile:C:\etc\traefik\'
deploy:
labels:
- traefik.enable=true
- traefik.docker.network=test_net
- traefik.docker.lbswarm=true
- traefik.instance=traefik1
- traefik.http.routers.internal-router-traefik1.rule=Host(`traefik1`)
- traefik.http.routers.internal-router-traefik1.entrypoints=internal1
- traefik.http.services.traefik2.loadbalancer.server.port=443
- traefik.http.services.traefik2.loadbalancer.server.scheme=https
- traefik.http.middlewares.https-redirectscheme.redirectscheme.scheme=https
- traefik.http.middlewares.https-redirectscheme.redirectscheme.port=443
- traefik.http.middlewares.https-redirect-url.redirectregex.regex=^(.*)traefik1/(.*)
- traefik.http.middlewares.https-redirect-url.redirectregex.replacement=https://traefik2/$${1}
- traefik.http.routers.internal-router-traefik1.middlewares=https-redirect-url@docker
- traefik.http.routers.internal-router-traefik1.middlewares=https-redirectscheme@docker
placement:
constraints: [node.hostname == DockerSwarm3]
networks:
test_net:
driver: overlay
config.toml:
[tls]
[[tls.certificates]]
certFile = "C:/keys/certificate.crt"
keyFile = "C:/keys/privateKey.key"
stores = ["default"]
[tls.stores]
[tls.stores.default]
[tls.stores.default.defaultCertificate]
certFile = "C:/keys/certificate.crt"
keyFile = "C:/keys/privateKey.key"
In the logs I only see the message that says the configuration was loaded.
Thanks for the help, hope I made it clear.