Nextcloud / Traefik uncooperative (redirecting to https://_/)

I’m running a whole suite of linuxserver containers using docker-compose and Ironic Badger’s awesome Debian server guide. While I began using dynamic DNS (ddns.info) in the first instance, I’ve since gotten a proper domain name and a static IP address and have begun migrating all my services to sit behid a reverse proxy and use lets-encrypt. For reasons I won’t go into here, the lsio lets encrypt image didn’t work for me, so I’m using traefik with a wildcard subdomain which works quite well for nearly everything, except Nextcloud. Nextcloud hums along just fine, and then when I enable traefik (config samples beow), it becomes suddenly inaccessible, that is, the server redirects me to https://_/ with a 301. I’ve been through quite a lot of scenarios, and I think I’ve isolated the issue to the configuration of the lsio nextcloud container, but am struggling to identify the next steps for troubleshooting (in part because I’m not an nginx expert - but rather an old apache hand).

Relevant docker-compose.yml samples:

  traefik:
    # Note: upgrade to traefik 2 requires major migration, so holding at 1.7 for now
    image: traefik:v1.7.19 # The official Traefik docker image
    container_name: traefik
    restart: always
    command: --api --docker --configFile=/traefik.toml # Enables the web UI and tells Traefik to listen to docker
    restart: unless-stopped
    networks:
      traefik_proxy:
    ports:
      - "80:80"     # The HTTP port
      - "443:443"   # HTTPS
    labels:
      - "traefik.enable=true"
      - "traefik.backend=traefik"
      - "traefik.frontend.rule=Host:traefik.my.dns"
      - "traefik.port=8080"
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock # So that Traefik can listen to the Docker events
      - /opt/appdata/traefik/traefik.toml:/traefik.toml
      - /opt/appdata/traefik/acme.json:/acme.json
      - /opt/appdata/traefik/log:/log
    env_file:
      - /opt/traefik.env
nextcloud-mariadb:
    image: linuxserver/mariadb
    container_name: nextcloud-mariadb
    labels:
      - "traefik.enable=false"
    networks:
      nextcloud:
    volumes:
      - /opt/appdata/mariadb:/config
    restart: always
    environment:
      - MYSQL_ROOT_PASSWORD=blahblahblah
  nextcloud:
    image: linuxserver/nextcloud
    container_name: nextcloud
    networks:
      traefik_proxy:
      nextcloud:
    labels:
#     disable traefik:
      - "traefik.enable=false"
#     basic options
#      - "traefik.backend=nextcloud"
#      - "traefik.docker.network=traefik_proxy"
#      - "traefik.enable=true"
#      - "traefik.frontend.rule=Host:nextcloud.my.dns"
#      - "traefik.port=80"
#      - "traefik.protocol=http"
    volumes:
      - /opt/appdata/nextcloud:/config
      - /mnt/disk1/nextcloud:/data
    ports:
      - "4003:443"
    restart: always
    depends_on:
      - nextcloud-mariadb
    links:
      - nextcloud-mariadb:mariadb
    environment:
      - PUID=${PUID}
      - PGID=${PGID}

Simply invert comments on relevant lines under nextcloud container config to see how I’m trying to get it working under traefik.

What I’ve done:

  • Edited /opt/appdata/nextcloud/www/nextcloud/config/config.php, 'trusted_domains' => array () to include new domain.
  • Deleted /config/nginx/site-confs/default (was hoping this would resolve issue, but no effect)
  • DNS zone file changes unnecessary as the wildcard config I have set up with traefik is working fine already.

Any ideas? Happy to provide more information if there’s anything relevant I’m leaving out here. Thanks in advance for the help!

I’m using traefik V2 and facing the same issue. I have an airsonic container and whoami container that both work correctly but I also get this weird redirect with the Nextcloud container.

@kidwellj @brakedust Did you found solution? I have the same issue with Nextcloud and Traefik

you guys are better off asking the traefik people about this. The LSIO team all uses the letsencrypt container, which works fine with nextcloud.