2017-07-31 35 views
0

我使用沒有traefik.toml的traefik,只有一個docker-compose.ymal文件。除了一件事之外,我設法做任何我想做的事情:自動將一項服務從http重定向到https。 這可能嗎?Traefik:如何僅使用docker-compose.yml重定向?

這裏是我的泊塢窗,撰寫(提取物)

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

+0

太需要回答的問題較少的信息。沒有關於docker-compose中運行的服務的信息?哪個服務器用於重定向?你現在如何嘗試重定向?請詳細說明是否需要幫助的問題 –

回答

0

嘗試將此添加到命令:

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

代替

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

+0

好吧,它就像一個魅力。謝謝。 –