Nextcloud Container: The page isn’t redirecting properly in Firefox and ERR_TOO_MANY_REDIRECTS in Chrome

Hi! I’m trying to use Linuxserver.io Container for Nextcloud. My setup is quite simple: I have the Traefik and Nextcloud containers. I have tested my Traefik configuration with Portainer and Whoami images and it worked fine. But I can’t make the Nextcloud container work. When I access my subdomain with Nextcloud, I only get “The page isn’t redirecting properly” in Firefox and ERR_TOO_MANY_REDIRECTS in Chrome.

version: "3.7"

services:

  traefik:
    image: "traefik:v2.1"
    container_name: "traefik"
    command:
      - "--api.dashboard=true"
      - "--providers.docker=true"
      - "--providers.docker.exposedbydefault=false"
      - "--entrypoints.web.address=:80"
      - "--entrypoints.websecure.address=:443"
      - "--certificatesresolvers.letsencrypttls.acme.tlschallenge=true"
      - "--certificatesresolvers.letsencrypttls.acme.email=myemail@mydomain.com"
      - "--certificatesresolvers.letsencrypttls.acme.storage=/letsencrypt/acme.json"
    ports:
      - "80:80"
      - "443:443"
      - "8080:8080"
    volumes:
      - "./letsencrypt:/letsencrypt"
      - "/var/run/docker.sock:/var/run/docker.sock:ro"
    restart: always
    labels:
      # HTTP-to-HTTPS Redirect
      - "traefik.http.routers.http-catchall.entrypoints=web"
      - "traefik.http.routers.http-catchall.rule=HostRegexp(`{host:.+}`)"
      - "traefik.http.routers.http-catchall.middlewares=redirect-to-https"
      - "traefik.http.middlewares.redirect-to-https.redirectscheme.scheme=https"

  nextcloud:
    container_name: nextcloud
    image: linuxserver/nextcloud:18.0.1-ls65
    restart: always
    volumes:
      - ./nextcloud:/config
      - ./nextcloud-files:/data
      - ./nextcloud-backup:/backup:ro
    environment:
      - TZ=Europe/Berlin
      - PUID=1000
      - PGID=999
    labels:
      - "traefik.enable=true"
      - "traefik.http.routers.nextcloud.rule=Host(`nextcloud.mydomain.com`)"
      - "traefik.http.routers.nextcloud.entrypoints=websecure"
      - "traefik.http.routers.nextcloud.tls.certresolver=letsencrypttls"

I also tried to set 'overwriteprotocol' => 'http' and to add my domain to trusted_domains in config.php, but it didn’t help.

Any idea how to fix the redirection problem? Thank you in advance.

I know none of the linuxserver team use Traefik, we all use our own LetsEncrypt container, so we can’t really help you with this.

I use Nextcloud with our LetsEncrypt container without issue, so I think it’s safe to assume it’s a Traefik issue.

Hopefully another member of the community may be able to help you.

I don’t think this is a Traefik issue: official Nextcloud image works fine with the same configuration as in my message.

It’s not a nextcloud image issue. Nextcloud listens on port 443 (https) with self signed certs. You need to tell your reverse proxy to connect to it via https on port 443