Traefik服务器:重定向次数过多

时间:2020-06-19 08:23:54

标签: https docker-compose traefik

这是我的情况:

在我公司中,我们有一个外部反向代理,它可以根据项目重定向到内部的服务器,因此我们可以使用HTTPS进行外部连接。

对于我来说,我有以下docker-compose.yml,它有两个服务器和一个traefik服务作为侦听端口80的入口点:

version: '3.7'

services: 

    traefik:
        image: "traefik:v2.2"
        container_name: "traefik"
        ports:
            - "80:80"
        networks: 
            - pg_database
        volumes:
            - "/var/run/docker.sock:/var/run/docker.sock:ro"
        command: 
            # entrypoints
            - "--entrypoints.web.address=:80"
            # providers
            - "--providers.docker=true"
            - "--providers.docker.endpoint=unix:///var/run/docker.sock"
            - "--providers.docker.exposedByDefault=false"

    service_one:
        image: custom-image
        restart: always
        expose:
            - 3000
        networks:
            - pg_database
        labels:
            # Explicitly tell Traefik to expose this container
            - "traefik.enable=true"
            # Add middleware path replace: /dashboard(/.*)? -> $1
            - "traefik.http.middlewares.pathreplacemiddleware.replacepathregex.regex=^\\/dashboard(\\/.*)?"
            - "traefik.http.middlewares.pathreplacemiddleware.replacepathregex.replacement=$$1"
            # Configure router (HTTP)
            - "traefik.http.routers.service_one_http.rule=Host(`mydomain.com`) && PathPrefix(`/dashboard/`)"
            - "traefik.http.routers.service_one_http.entrypoints=web"
            - "traefik.http.routers.service_one_http.middlewares=pathreplacemiddleware"
            - "traefik.http.routers.service_one_http.priority=2"

    service_two:
        image: custom-image
        expose:
            - 3000
        networks: 
            - pg_database
        labels:
            # Explicitly tell Traefik to expose this container
            - "traefik.enable=true"
            # Configure router (HTTP)
            - "traefik.http.routers.service_two_http.rule=Host(`mydomain.com`)"
            - "traefik.http.routers.service_two_http.entrypoints=web"
            - "traefik.http.routers.service_two_http.priority=1"

networks:
    pg_database:
        external: true

直接从公司内部网络访问端口80(http)上没有问题。问题是,当您尝试从外部通过https进行访问时,页面无法加载并显示以下错误:ERR_TOO_MANY_REDIRECTS

如您所见,traefik中没有任何重定向规则,所以我不知道可能会发生什么。

0 个答案:

没有答案