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 also gather that others have experienced this same issue in Traefik v2 (cf. here https://discourse.linuxserver.io/t/nextcloud-traefik-uncooperative-redirecting-to-https/919).

Just FYI, in case anyone else wanders over here and wonders. I’ve resolved the issue, thanks to a tip by a user on the nextcloud forum. You can read it here: https://help.nextcloud.com/t/nextcloud-migration-to-traefik-failing-looking-for-help-troubleshooting/79129/2. Essentially, I needed to modify the listen directive in nginx/site-confs/default to be sure that it wasn’t redirecting port 80 traffic to 443 (which I believe is, or at least was, default behaviour for this container at some point in the past). Working like a charm with traefik on my homeserver now.

1 Like

I just stuff 2 days in this one, can you put the example of nginx/site-confs/default file?
I wonder should I remove it or change it, and I also does not clear about config.php file (trusted_host). Can you also put example for that?
Thank you so much!!!