Since update: Nextcloud cannot reach Nginx proxy any longer, works okay from outside

Since updating Nextcloud I have the issue that Nextcloud itself is not able to reach the Nginx Proxy any longer and I am getting the error

Your web server is not yet properly set up to allow file synchronization, because the WebDAV interface seems to be broken. To allow this check to run you have to make sure that your webserver can connect to itself. Therefor it must be able to resolve and connect to at least one its trusted_domains or the overwrite.cli.url.

I have played around with trusted_domains and overwrite.cli.url but nothing so far helped (and they had not changed during the update where the issue started to occur, of course). Instead, I suspect that Nextcloud cannot reach the Proxy because it does not specify the correct hostname (nas.mypage.de) and instead only the IP on its request. But the request itself reaches the proxy as it shows up in the logs (below).

When I load the admin overview page https://nas.mypage.de:42443/settings/admin/overview I get (among others) the above quoted error and can see in the Nginx proxy logs:

nginx.1     | 100.117.32.109 172.22.0.1 - - [25/Sep/2024:21:19:07 +0000] "PROPFIND /remote.php/webdav HTTP/1.1" 400 248 "-" "Nextcloud Server Crawler" "-"

Here I interpret that Nextcloud is not using the correct host nas.mypage.de and instead only the proxy’s IP, and therefore the request fails. Compare a successful request to the proxy from my laptop:

nginx.1     | nas.mypage.de 62.226.219.xxx - - [25/Sep/2024:21:19:04 +0000] "GET /index.php/apps/files/preview-service-worker.js HTTP/2.0" 200 5253 "-" "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:130.0) Gecko/20100101 Firefox/130.0" "172.22.0.3:80"

nextcloud_proxy Docker IP: 172.22.0.2
nextcloud_app Docker IP: 172.22.0.3
LAN IP of the physical host machine running Docker: 100.117.32.109

Can you please help me figure out why this is the case, whether my suspicion is correct, and how I can fix this? I am worried about updating the instance further and messing more things up. Accessing the instance/proxy from external devices works fine.

Nextcloud version: Docker nextcloud:29.0.4-apache
Operating system and version: Ubuntu 22.04.3 + Docker
Apache or nginx version: Docker nginx-proxy:1.6-alpine as proxy

Nextcloud config.php:

<?php
$CONFIG = array (
  'htaccess.RewriteBase' => '/',
  'memcache.local' => '\\OC\\Memcache\\APCu',
  'apps_paths' =>
  array (
    0 =>
    array (
      'path' => '/var/www/html/apps',
      'url' => '/apps',
      'writable' => false,
    ),
    1 =>
    array (
      'path' => '/var/www/html/custom_apps',
      'url' => '/custom_apps',
      'writable' => true,
    ),
  ),
  'memcache.distributed' => '\\OC\\Memcache\\Redis',
  'memcache.locking' => '\\OC\\Memcache\\Redis',
  'redis' =>
  array (
    'host' => 'redis',
    'password' => '',
    'port' => 6379,
  ),
  'instanceid' => 'xxx',
  'passwordsalt' => 'xxx',
  'secret' => 'xxx',
  'trusted_domains' =>
  array (
    0 => '100.117.32.109:42443',
    1 => 'nas.mypage.de:42443',
  ),
  'datadirectory' => '/var/www/html/data',
  'dbtype' => 'mysql',
  'version' => '29.0.4.1',
  'overwrite.cli.url' => 'https://nas.mypage.de:42443',
  'dbname' => 'nextcloud',
  'dbhost' => 'db',
  'dbport' => '',
  'dbtableprefix' => 'oc_',
  'mysql.utf8mb4' => true,
  'dbuser' => 'nextcloud',
  'dbpassword' => 'xxx',
  'installed' => true,
  'overwriteprotocol' => 'https',
  'overwritehost' => 'nas.mypage.de:42443',
  #'overwritecondaddr' => '^172\.22\.0\.2$',
  'default_phone_region' => 'DE',
  'defaultapp' => 'files',
  'mail_smtpmode' => 'smtp',
  'mail_smtphost' => 'smtp.mailbox.org',
  'mail_sendmailmode' => 'smtp',
  'mail_from_address' => 'noreply',
  'mail_domain' => 'mypage.de',
  'mail_smtpsecure' => 'ssl',
  'mail_smtpauthtype' => 'LOGIN',
  'mail_smtpauth' => 1,
  'mail_smtpport' => '465',
  'mail_smtpname' => 'yyy@mypage.de',
  'mail_smtppassword' => 'xxx',
  'maintenance' => false,
  'maintenance_window_start' => 1,
  'theme' => '',
  'loglevel' => 2,
  'trusted_proxies' =>
  array (
    0 => '172.22.0.2/16',
  ),
  'memories.exiftool' => '/var/www/html/custom_apps/memories/bin-ext/exiftool-amd64-glibc',
  'memories.vod.path' => '/var/www/html/custom_apps/memories/bin-ext/go-vod-amd64',
  'memories.db.triggers.fcu' => true,
);

I am using docker-compose for the server. The docker-compose.yml is:

version: '3'

services:
  nginx-proxy:
    image: nginxproxy/nginx-proxy:1.6-alpine
    container_name: nextcloud_proxy
    restart: unless-stopped
    ports:
     - 42443:42443
    volumes:
      - ./proxy/vhost.d:/etc/nginx/vhost.d
      - ./letsencrypt:/etc/nginx/certs
      - /var/run/docker.sock:/tmp/docker.sock:ro
    environment:
      - HTTPS_PORT=42443
      - DEFAULT_HOST=nas.mypage.de
    depends_on:
      - app
    networks:
      - frontend

  dnsrobocert:
    image: adferrand/dnsrobocert
    container_name: nextcloud_dnsrobocert
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock
      - ./letsencrypt:/etc/letsencrypt
      - ./dnsrobocert:/etc/dnsrobocert
    restart: unless-stopped
    depends_on:
      - nginx-proxy

  db:
    image: mariadb:10.5
    container_name: nextcloud_db
    command: --transaction-isolation=READ-COMMITTED --binlog-format=ROW
    restart: unless-stopped
    volumes:
      - db:/var/lib/mysql
    environment:
      - MYSQL_ROOT_PASSWORD=xxx
      - MARIADB_AUTO_UPGRADE=1
      - MARIADB_DISABLE_UPGRADE_BACKUP=1
    env_file:
      - db.env

  redis:
    image: redis:alpine
    container_name: nextcloud_redis
    restart: unless-stopped

  app:
    image: nextcloud:29.0.4-apache
    container_name: nextcloud_app
    restart: unless-stopped
    volumes:
      - nextcloud:/var/www/html
      - ./app/config:/var/www/html/config
      - ./app/custom_apps:/var/www/html/custom_apps
      - ./app/data:/var/www/html/data
      - ./app/themes:/var/www/html/themes
    environment:
      - MYSQL_HOST=db
      - REDIS_HOST=redis
      - PHP_UPLOAD_LIMIT=10G
      - PHP_MEMORY_LIMIT=1G
      - VIRTUAL_HOST=nas.mypage.de
    env_file:
      - db.env
    depends_on:
      - db
      - redis
    networks:
      - frontend
      - default

  cron:
    image: nextcloud:29.0.4-apache
    container_name: nextcloud_cron
    restart: unless-stopped
    volumes:
      - nextcloud:/var/www/html
      - ./app/config:/var/www/html/config
      - ./app/custom_apps:/var/www/html/custom_apps
      - ./app/data:/var/www/html/data
      - ./app/themes:/var/www/html/themes
    entrypoint: /cron.sh
    env_file:
      - db.env
    depends_on:
      - db
      - redis
      - app

volumes:
  db:
  nextcloud:

networks:
  frontend:

I had tried adding the DEFAULT_HOST=nas.mypage.de to the proxy settings in order to solve my issue, but sadly it has not helped.

Error in the setup checks seems similar, but also different (not nginx) and without a clear solution.

I have had tried to solve this issue for over a month, but of course 10 minutes after submitting the post I found a solution…
I actually found out after entering the nextcloud_app Docker container with docker exec -it nextcloud_app bash and trying to ping nas.mypage.de (after installing iputils-ping) that no connection to nas.mypage.de was possible. I’m not quite sure anymore which IP it was trying to use, but definitely not the Docker network one of the proxy.
After adding an entry with the Proxy’s Docker network IP to /etc/hosts in the nextcloud_app continer, the error was gone! To have this change persist, I added an extra_hosts entry to the docker-compose.yml and now all is good again.
Probably I should not hardcode the proxy’s IP (as it’s chosen automatically and not by me), but for now that is okay with me… If anyone has a better suggestion than

    extra_hosts:
      - "nas.mypage.de:172.22.0.2"

I am all ears!

This topic was automatically closed 8 days after the last reply. New replies are no longer allowed.