title: Configuration Nextcloud on Docker behind Traefik
body: <p>I'm quite new to Docker, and I'm trying to get Nextcloud to work as a subfolder of my domain behind the reverse-proxy Traefik.</p>
  <p>The problem is a little weird, I can make work as a subdomain of my duckdns address nextcloud.XXX.duckdns.org, but not as a subfolder XXX.duckdns.org/nextcloud.
  I prefer the subfolder approach, but i'm having some trouble and it's driving me crazy ^^</p>
  <p>Can anyone help me figure out how to make this work ?</p>
  <p>I'm running on a Raspberry Pi 4 with 8GB of ram.
  Here is my config.php:</p>
  <pre><code>&lt;?php
  $CONFIG = array (
    'htaccess.RewriteBase' =&gt; '/',
    'memcache.local' =&gt; '\\OC\\Memcache\\APCu',
    'apps_paths' =&gt;
    array (
      0 =&gt;
      array (
        'path' =&gt; '/var/www/html/apps',
        'url' =&gt; '/apps',
        'writable' =&gt; false,
      ),
      1 =&gt;
      array (
        'path' =&gt; '/var/www/html/custom_apps',
        'url' =&gt; '/custom_apps',
        'writable' =&gt; true,
      ),
    ),
    'overwritehost' =&gt; 'XXX.duckdns.org',
    'overwriteprotocol' =&gt; 'https',
    'overwritewebroot' =&gt; '/nextcloud',
    'trusted_proxies' =&gt;
    array (
      0 =&gt; 'traefik',
    ),
    'passwordsalt' =&gt; 'XXX',
    'secret' =&gt; 'XXX',
    'trusted_domains' =&gt;
    array (
      0 =&gt; 'localhost',
      1 =&gt; '0.0.0.0:85',
      2 =&gt; '10.0.0.3:85',
      3 =&gt; 'XXX.duckdns.org',
    ),
    'datadirectory' =&gt; '/var/www/html/data',
    'dbtype' =&gt; 'mysql',
    'version' =&gt; '19.0.3.1',
    'overwrite.cli.url' =&gt; 'https://XXX.duckdns.org/nextcloud',
    'loglevel' =&gt; 0,
    'dbname' =&gt; 'nextcloud',
    'dbhost' =&gt; 'db-nextcloud-maria',
    'dbport' =&gt; '',
    'dbtableprefix' =&gt; 'oc_',
    'dbuser' =&gt; 'nextcloud',
    'dbpassword' =&gt; 'XXXXXXXXXXX',
    'installed' =&gt; true,
    'instanceid' =&gt; 'ocnhvv6wef7n',
  );
  </code></pre>
  <p>and when I try to access it, the docker log nextcloud is:</p>
  <pre><code>AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using 172.27.0.9. Set the 'ServerName' directive globally to suppress this message
  AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using 172.27.0.9. Set the 'ServerName' directive globally to suppress this message
  [Wed Sep 23 16:57:39.710120 2020] [mpm_prefork:notice] [pid 1] AH00163: Apache/2.4.38 (Debian) PHP/7.4.10 configured -- resuming normal operations
  [Wed Sep 23 16:57:39.710272 2020] [core:notice] [pid 1] AH00094: Command line: 'apache2 -D FOREGROUND'
  172.27.0.7 - XXX [23/Sep/2020:16:58:27 +0200] &quot;GET /nextcloud HTTP/1.1&quot; 302 413 &quot;https://XXX.duckdns.org/&quot; &quot;Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:81.0) Gecko/20100101 Firefox/81.0&quot;
  172.27.0.7 - XXX [23/Sep/2020:16:58:27 +0200] &quot;GET /nextcloud/ HTTP/1.1&quot; 302 1126 &quot;-&quot; &quot;Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:81.0) Gecko/20100101 Firefox/81.0&quot;
  172.27.0.7 - XXX [23/Sep/2020:16:58:29 +0200] &quot;GET /nextcloud/login HTTP/1.1&quot; 302 1018 &quot;-&quot; &quot;Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:81.0) Gecko/20100101 Firefox/81.0&quot;
  172.27.0.7 - XXX [23/Sep/2020:16:58:31 +0200] &quot;GET /nextcloud/login HTTP/1.1&quot; 302 1018 &quot;-&quot; &quot;Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:81.0) Gecko/20100101 Firefox/81.0&quot;
  172.27.0.7 - XXX [23/Sep/2020:16:58:34 +0200] &quot;GET /nextcloud/login HTTP/1.1&quot; 302 1018 &quot;-&quot; &quot;Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:81.0) Gecko/20100101 Firefox/81.0&quot;
  172.27.0.7 - XXX [23/Sep/2020:16:58:36 +0200] &quot;GET /nextcloud/login HTTP/1.1&quot; 302 1018 &quot;-&quot; &quot;Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:81.0) Gecko/20100101 Firefox/81.0&quot;
  172.27.0.7 - XXX [23/Sep/2020:16:58:40 +0200] &quot;GET /nextcloud/login HTTP/1.1&quot; 302 1018 &quot;-&quot; &quot;Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:81.0) Gecko/20100101 Firefox/81.0&quot;
  </code></pre>
  <p>and nextcloud.log:</p>
  <pre><code>{&quot;reqId&quot;:&quot;hC8j9LCSu628oxhX0Uav&quot;,&quot;level&quot;:2,&quot;time&quot;:&quot;2020-09-23T14:58:29+00:00&quot;,&quot;remoteAddr&quot;:&quot;172.27.0.7&quot;,&quot;user&quot;:&quot;--&quot;,&quot;app&quot;:&quot;core&quot;,&quot;method&quot;:&quot;GET&quot;,&quot;url&quot;:&quot;/nextcloud/index.php/&quot;,&quot;message&quot;:&quot;Login failed: 'XXX' (Remote IP: '172.27.0.7')&quot;,&quot;userAgent&quot;:&quot;Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:81.0) Gecko/20100101 Firefox/81.0&quot;,&quot;version&quot;:&quot;19.0.3.1&quot;}
  {&quot;reqId&quot;:&quot;hC8j9LCSu628oxhX0Uav&quot;,&quot;level&quot;:1,&quot;time&quot;:&quot;2020-09-23T14:58:29+00:00&quot;,&quot;remoteAddr&quot;:&quot;172.27.0.7&quot;,&quot;user&quot;:&quot;--&quot;,&quot;app&quot;:&quot;core&quot;,&quot;method&quot;:&quot;GET&quot;,&quot;url&quot;:&quot;/nextcloud/index.php/&quot;,&quot;message&quot;:&quot;Bruteforce attempt from \&quot;172.27.0.7\&quot; detected for action \&quot;login\&quot;.&quot;,&quot;userAgent&quot;:&quot;Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:81.0) Gecko/20100101 Firefox/81.0&quot;,&quot;version&quot;:&quot;19.0.3.1&quot;}
  {&quot;reqId&quot;:&quot;FKD3SVW1NI1VqBUHBwUg&quot;,&quot;level&quot;:2,&quot;time&quot;:&quot;2020-09-23T14:58:31+00:00&quot;,&quot;remoteAddr&quot;:&quot;172.27.0.7&quot;,&quot;user&quot;:&quot;--&quot;,&quot;app&quot;:&quot;core&quot;,&quot;method&quot;:&quot;GET&quot;,&quot;url&quot;:&quot;/nextcloud/index.php/login&quot;,&quot;message&quot;:&quot;Login failed: 'XXX' (Remote IP: '172.27.0.7')&quot;,&quot;userAgent&quot;:&quot;Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:81.0) Gecko/20100101 Firefox/81.0&quot;,&quot;version&quot;:&quot;19.0.3.1&quot;}
  {&quot;reqId&quot;:&quot;FKD3SVW1NI1VqBUHBwUg&quot;,&quot;level&quot;:1,&quot;time&quot;:&quot;2020-09-23T14:58:31+00:00&quot;,&quot;remoteAddr&quot;:&quot;172.27.0.7&quot;,&quot;user&quot;:&quot;--&quot;,&quot;app&quot;:&quot;core&quot;,&quot;method&quot;:&quot;GET&quot;,&quot;url&quot;:&quot;/nextcloud/index.php/login&quot;,&quot;message&quot;:&quot;Bruteforce attempt from \&quot;172.27.0.7\&quot; detected for action \&quot;login\&quot;.&quot;,&quot;userAgent&quot;:&quot;Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:81.0) Gecko/20100101 Firefox/81.0&quot;,&quot;version&quot;:&quot;19.0.3.1&quot;}
  {&quot;reqId&quot;:&quot;U8xWlVN1rX4aM46TpxWK&quot;,&quot;level&quot;:2,&quot;time&quot;:&quot;2020-09-23T14:58:34+00:00&quot;,&quot;remoteAddr&quot;:&quot;172.27.0.7&quot;,&quot;user&quot;:&quot;--&quot;,&quot;app&quot;:&quot;core&quot;,&quot;method&quot;:&quot;GET&quot;,&quot;url&quot;:&quot;/nextcloud/index.php/login&quot;,&quot;message&quot;:&quot;Login failed: 'XXX' (Remote IP: '172.27.0.7')&quot;,&quot;userAgent&quot;:&quot;Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:81.0) Gecko/20100101 Firefox/81.0&quot;,&quot;version&quot;:&quot;19.0.3.1&quot;}
  {&quot;reqId&quot;:&quot;U8xWlVN1rX4aM46TpxWK&quot;,&quot;level&quot;:1,&quot;time&quot;:&quot;2020-09-23T14:58:34+00:00&quot;,&quot;remoteAddr&quot;:&quot;172.27.0.7&quot;,&quot;user&quot;:&quot;--&quot;,&quot;app&quot;:&quot;core&quot;,&quot;method&quot;:&quot;GET&quot;,&quot;url&quot;:&quot;/nextcloud/index.php/login&quot;,&quot;message&quot;:&quot;Bruteforce attempt from \&quot;172.27.0.7\&quot; detected for action \&quot;login\&quot;.&quot;,&quot;userAgent&quot;:&quot;Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:81.0) Gecko/20100101 Firefox/81.0&quot;,&quot;version&quot;:&quot;19.0.3.1&quot;}
  {&quot;reqId&quot;:&quot;HTYtffzeLAghfkSjUcuA&quot;,&quot;level&quot;:2,&quot;time&quot;:&quot;2020-09-23T14:58:36+00:00&quot;,&quot;remoteAddr&quot;:&quot;172.27.0.7&quot;,&quot;user&quot;:&quot;--&quot;,&quot;app&quot;:&quot;core&quot;,&quot;method&quot;:&quot;GET&quot;,&quot;url&quot;:&quot;/nextcloud/index.php/login&quot;,&quot;message&quot;:&quot;Login failed: 'XXX' (Remote IP: '172.27.0.7')&quot;,&quot;userAgent&quot;:&quot;Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:81.0) Gecko/20100101 Firefox/81.0&quot;,&quot;version&quot;:&quot;19.0.3.1&quot;}
  {&quot;reqId&quot;:&quot;HTYtffzeLAghfkSjUcuA&quot;,&quot;level&quot;:1,&quot;time&quot;:&quot;2020-09-23T14:58:36+00:00&quot;,&quot;remoteAddr&quot;:&quot;172.27.0.7&quot;,&quot;user&quot;:&quot;--&quot;,&quot;app&quot;:&quot;core&quot;,&quot;method&quot;:&quot;GET&quot;,&quot;url&quot;:&quot;/nextcloud/index.php/login&quot;,&quot;message&quot;:&quot;Bruteforce attempt from \&quot;172.27.0.7\&quot; detected for action \&quot;login\&quot;.&quot;,&quot;userAgent&quot;:&quot;Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:81.0) Gecko/20100101 Firefox/81.0&quot;,&quot;version&quot;:&quot;19.0.3.1&quot;}
  {&quot;reqId&quot;:&quot;tGKAlT6DUn9cVTYbZUmd&quot;,&quot;level&quot;:2,&quot;time&quot;:&quot;2020-09-23T14:58:40+00:00&quot;,&quot;remoteAddr&quot;:&quot;172.27.0.7&quot;,&quot;user&quot;:&quot;--&quot;,&quot;app&quot;:&quot;core&quot;,&quot;method&quot;:&quot;GET&quot;,&quot;url&quot;:&quot;/nextcloud/index.php/login&quot;,&quot;message&quot;:&quot;Login failed: 'XXX' (Remote IP: '172.27.0.7')&quot;,&quot;userAgent&quot;:&quot;Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:81.0) Gecko/20100101 Firefox/81.0&quot;,&quot;version&quot;:&quot;19.0.3.1&quot;}
  {&quot;reqId&quot;:&quot;tGKAlT6DUn9cVTYbZUmd&quot;,&quot;level&quot;:1,&quot;time&quot;:&quot;2020-09-23T14:58:40+00:00&quot;,&quot;remoteAddr&quot;:&quot;172.27.0.7&quot;,&quot;user&quot;:&quot;--&quot;,&quot;app&quot;:&quot;core&quot;,&quot;method&quot;:&quot;GET&quot;,&quot;url&quot;:&quot;/nextcloud/index.php/login&quot;,&quot;message&quot;:&quot;Bruteforce attempt from \&quot;172.27.0.7\&quot; detected for action \&quot;login\&quot;.&quot;,&quot;userAgent&quot;:&quot;Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:81.0) Gecko/20100101 Firefox/81.0&quot;,&quot;version&quot;:&quot;19.0.3.1&quot;}
  {&quot;reqId&quot;:&quot;bApTkgFPNyNyHhY87pw7&quot;,&quot;level&quot;:2,&quot;time&quot;:&quot;2020-09-23T14:58:45+00:00&quot;,&quot;remoteAddr&quot;:&quot;172.27.0.7&quot;,&quot;user&quot;:&quot;--&quot;,&quot;app&quot;:&quot;core&quot;,&quot;method&quot;:&quot;GET&quot;,&quot;url&quot;:&quot;/nextcloud/index.php/login&quot;,&quot;message&quot;:&quot;Login failed: 'XXX' (Remote IP: '172.27.0.7')&quot;,&quot;userAgent&quot;:&quot;Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:81.0) Gecko/20100101 Firefox/81.0&quot;,&quot;version&quot;:&quot;19.0.3.1&quot;}
  {&quot;reqId&quot;:&quot;bApTkgFPNyNyHhY87pw7&quot;,&quot;level&quot;:1,&quot;time&quot;:&quot;2020-09-23T14:58:45+00:00&quot;,&quot;remoteAddr&quot;:&quot;172.27.0.7&quot;,&quot;user&quot;:&quot;--&quot;,&quot;app&quot;:&quot;core&quot;,&quot;method&quot;:&quot;GET&quot;,&quot;url&quot;:&quot;/nextcloud/index.php/login&quot;,&quot;message&quot;:&quot;Bruteforce attempt from \&quot;172.27.0.7\&quot; detected for action \&quot;login\&quot;.&quot;,&quot;userAgent&quot;:&quot;Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:81.0) Gecko/20100101 Firefox/81.0&quot;,&quot;version&quot;:&quot;19.0.3.1&quot;}
  </code></pre>
  <p>My docker-compose for nextcloud is</p>
  <pre><code>nextcloud:
      image: nextcloud
      container_name: nextcloud
      restart: unless-stopped
      volumes:
        - /etc/localtime:/etc/localtime:ro
        - ${DOCKERCONFDIR}/nextcloud:/var/www/html
      depends_on:
        - db-nextcloud-maria
      environment:
        - MYSQL_HOST=db-nextcloud-maria
        - MYSQL_DATABASE=${MARIADB_MYSQL_DATABASE}
        - MYSQL_USER=${MARIADB_MYSQL_USER}
        - MYSQL_PASSWORD=${MARIADB_MYSQL_PASSWORD}
        - NEXTCLOUD_ADMIN_USER=${NEXTCLOUD_ADMIN_USER}
        - NEXTCLOUD_ADMIN_PASSWORD=${NEXTCLOUD_ADMIN_PASSWORD}
        - NEXTCLOUD_TRUSTED_DOMAINS=${NEXTCLOUD_TRUSTED_DOMAINS}
        - TRUSTED_PROXIES=traefik
        - OVERWRITEHOST=${NEXTCLOUD_OVERWRITEHOST}
        - OVERWRITEPROTOCOL=https
        - OVERWRITEWEBROOT=${NEXTCLOUD_OVERWRITEWEBROOT}
      ports:
        - 85:80
      labels:
        - &quot;traefik.enable=true&quot;
        - &quot;traefik.http.routers.nextcloud.rule=(Host(`XXX.duckdns.org`) &amp;&amp; PathPrefix(`/nextcloud`))&quot;
        - &quot;traefik.http.routers.nextcloud.entrypoints=websecure&quot;
        - &quot;traefik.http.routers.nextcloud.tls.certresolver=myresolver&quot;
  
  db-nextcloud-maria:
      image: linuxserver/mariadb
      container_name: db-nextcloud-maria
      hostname: ${DOCKERHOSTNAME}
      environment:
        - PGID=${PGID}
        - PUID=${PUID}
        - MYSQL_ROOT_PASSWORD=${MARIADB_MYSQL_ROOT_PASSWORD}
        - MYSQL_DATABASE=${MARIADB_MYSQL_DATABASE}
        - MYSQL_USER=${MARIADB_MYSQL_USER}
        - MYSQL_PASSWORD=${MARIADB_MYSQL_PASSWORD}
        - TZ=${TZ}
      logging:
        driver: json-file
        options:
          max-file: ${DOCKERLOGGING_MAXFILE}
          max-size: ${DOCKERLOGGING_MAXSIZE}
      restart: unless-stopped
      ports:
        - ${MARIADB_PORT_3306}:3306
      volumes:
        - /etc/localtime:/etc/localtime:ro
        - ${DOCKERCONFDIR}/db-nextcloud-maria:/config
  </code></pre>
  <p>Does anyone have any idea what's happening and how to solve it ?</p>
  <p>Many thanks to anyone who tries to help, this is driving me crazy :slight_smile:</p>