0

我使用没有 traefik.toml 的 traefik,只有一个 docker-compose.ymal 文件。我已经设法做任何我想做的事,除了一件事:自动将一项服务从 http 重定向到 https。可能吗 ?

这是我的 docker-compose (摘录)

    version: '2'
    services:
    ###################################
    #    TRAEFIK
    ###################################
        traefik:
            image: traefik:latest
            command: --web --docker --docker.domain=docker.localhost --logLevel=DEBUG --entryPoints='Name:https Address::443 TLS' --entryPoints='Name:http Address::80' --acme.entrypoint=https --acme=true --acme.domains="${BASE_URL}, ${ADMIN_URL}" --acme.email="${MAIL_ADDRESS}" --acme.ondemand=true acme.onhostrule=true --acme.storage=/certs/acme.json
            ports:
                - "80:80"
                - "443:443"
            volumes:
                - /var/run/docker.sock:/var/run/docker.sock
                - /dev/null:/traefik.toml
                - $CONFIG_DIR/traefik:/etc/traefik/acme
                - $CONFIG_DIR/certs:/certs
            labels:
                - "traefik.backend=traefik"
                - "traefik.frontend.rule=Host:${ADMIN_URL}"
                - "traefik.backend.port=8080"
                - "traefik.frontend.auth.basic=admin:${passwd_admin}"
                - "traefik.frontend.entryPoints=https"
        rutorrent-steph:
            image: xataz/rtorrent-rutorrent
            ports:
                - "45001:45001" #UserPort
            labels:
                - "traefik.backend=rutorrent_steph"
                - "traefik.frontend.rule=Host:${BASE_URL};PathPrefix:/steph_rutorrent"
                - "traefik.backend.port=8080"
                - "traefik.frontend.auth.basic=steph:${passwd_steph}"
                - "traefik.frontend.entryPoints=https,http"
            environment:
                - UID=${MYUID}
                - GID=${MYGID}
                - PORT_RTORRENT=45001
                - WEBROOT=/steph_rutorrent
            volumes:
                - $DATA_DIR/steph/data:/data
                - $DATA_DIR/steph/config/torrent:/config
            dns: 8.8.8.8

当我使用 http://{ BASE_URL}/steph_rutorrent 或 https://{ BASE_URL}/steph_rutorrent 时,它每次都有效。但我想确保如果我输入 http://{ BASE_URL}/steph_rutorrent 它将重定向到 https://{ BASE_URL}/steph_rutorrent

4

1 回答 1

1

尝试将其添加到命令中:

--entryPoints='Name:http Address::80 Redirect.EntryPoint:https'

代替

--entryPoints='Name:http Address::80'

于 2017-08-01T20:13:39.827 回答