Sporadisch keine Verbindung mehr zur Nextcloud

Hallo,

ich bin mit meiner bestehenden System auf einen Proxmox Server umgezogen.
Die NC (31.0.11) lÀuft nun auf einer Proxmox VM. Und mein Emby MediaServer auf einer zweiten VM

VM1 ist die Cloud auf Ubuntu 24.04
VM2 ist der EmbyMedia Server mit Debian.

Der Webserver auf VM1 ist Apache2
Gleichzeitig lÀuft auf dieser Maschine noch der Apache Reverse Proxy, der eine weitere Subdomain auf die IP der VM2 umleitet.

Alles funktioniert eigentlich wunderbar. Wenn ich die Cloud nicht anpacke, lÀuft alles total stabil.
Logge ich mich in die Cloud ein und öffne einige MenĂŒpunkte, kommt es frĂŒher oder spĂ€ter zu einer unterbrochenen Verbindung.
Dann ist die Cloud nicht mehr ĂŒber seine Subdomain zu erreichen und auch nicht mehr die zweite Maschine ĂŒber deren Subdomain.

Um das Problem zu lösen, muss ich die Internetverbindung neu aufbauen und dann natĂŒrlich meine neue IP mit inadyn neu ĂŒbermitteln. Dann lĂ€uft wieder alles rund.

Ich finde einfach den Fehler nicht.
Allerdings weiß ich auch ĂŒberhaupt nicht, wie ich da strukturiert den Fehler suchen soll.
Es scheint mir,dass die Nextcloud die Ursache ist, es sich aber dann bis auf den Reverse Proxy ausweitet.

Ich stelle mal die Konfiguration der config.php, des Reverse Proxys und die virtuellen Hosts hier rein.
Vielleicht findet ja jemand etwas raus oder hat eine Idee, wie man das angeht.

Ich bedanke mich schon einmal im Vorraus fĂŒr eure Zeit.

config.php

<?php
$CONFIG = array (
  'instanceid' => 'oceha13agv6u',
  'passwordsalt' => 'xxxxxxxxxxxxxxxxxxxxxxxx',
  'secret' => 'xxxxxxxxxxxxxxxxxxxxx',
  'trusted_domains' => 
  array (
    0 => '192.168.1.83',
    1 => '[2003:e2:d711:5a00:be24xxxxxxxxxxxx]',
    2 => 'cloud.xxx.eu',
    3 => '192.168.1.138',
  ),
  'trusted_proxies' => 
  array (
    0 => '127.0.0.1',
    1 => '::1',
  ),
  'datadirectory' => '/media/Daten',
  'dbtype' => 'mysql',
  'version' => '31.0.11.2',
  'overwrite.cli.url' => 'https://cloud.xxx.eu',
  'dbname' => 'xxx',
  'dbhost' => 'localhost',
  'dbport' => '',
  'dbtableprefix' => 'oc_',
  'mysql.utf8mb4' => true,
  'dbuser' => 'xxx',
  'dbpassword' => 'xxx',
  'loglevel' => 3,
  'log_type' => 'file',
  'logdateformat' => 'F d, Y H:i:s',
  'installed' => true,
  'memcache.local' => '\\OC\\Memcache\\APCu',
  'filelocking.enabled' => true,
  'memcache.locking' => '\\OC\\Memcache\\Redis',
  'redis' => 
  array (
    'host' => '/var/run/redis/redis-server.sock',
    'port' => 0,
    'password' => 'xxxxx',
    'timeout' => 0.0,
  ),
  'mail_from_address' => 'xxxx.cloud',
  'mail_smtpmode' => 'smtp',
  'mail_sendmailmode' => 'smtp',
  'mail_domain' => 'posteo.de',
  'mail_smtpauthtype' => 'LOGIN',
  'mail_smtphost' => 'posteo.de',
  'mail_smtpport' => '587',
  'mail_smtpsecure' => 'tls',
  'filesystem_check_changes' => 1,
  'maintenance' => false,
  'maintenance_window_start' => 1,
  'theme' => '',
  'trashbin_retention_obligation' => '14, 14',
  'preview_max_x' => 2048,
  'preview_max_y' => 2048,
  'preview_max_memory' => 1280,
  'jpeg_quality' => 60,
  'updater.release.channel' => 'stable',
  'default_phone_region' => 'DE',
  'app_install_overwrite' => 
  array (
    0 => 'bruteforcesettings',
    1 => 'end_to_end_encryption',
    2 => 'gpxpod',
    3 => 'maps',
  ),
  'mail_smtpauth' => 1,
  'mail_smtpname' => 'xxxxx@posteo.de',
  'mail_smtppassword' => 'xxxxxxxxxxxxxxxxxxxx',
  'memories.exiftool' => '/var/www/nextcloud/apps/memories/bin-ext/exiftool-amd64-glibc',
  'memories.vod.path' => '/var/www/nextcloud/apps/memories/bin-ext/go-vod-amd64',
  'ffmpeg' => '/usr/bin/ffmpeg',
  'enabledPreviewProviders' => 
  array (
    0 => 'OC\\Preview\\Image',
    1 => 'OC\\Preview\\TIFF',
    2 => 'OC\\Preview\\Movie',
  ),
  'memories.vod.disable' => false,
  'memories.vod.ffmpeg' => '/usr/bin/ffmpeg',
  'memories.vod.ffprobe' => '/usr/bin/ffprobe',
  'defaultapp' => '',
  'memories.gis_type' => 1,
  'memories.db.triggers.fcu' => true,
  'htaccess.RewriteBase' => '/',
);

Hier die beiden Konfigs der virtuellen Hosts

<IfModule mod_ssl.c>
#<VirtualHost *:443>
<VirtualHost *:443 [::]:443>
 ServerName cloud.xxx.eu
 Protocols h2 h2c http:/1.1
 DocumentRoot /var/www/nextcloud

  <IfModule mod_headers.c>
                Header always set Strict-Transport-Security "max-age=15552000"
                Redirect 301 /.well-known/carddav /remote.php/dav
                Redirect 301 /.well-known/caldav /remote.php/dav
        </IfModule>

   <Directory /var/www/nextcloud>
        Options +FollowSymlinks
        AllowOverride All
        Require all granted
       </Directory>



Include /etc/letsencrypt/options-ssl-apache.conf
SSLCertificateFile /etc/letsencrypt/live/cloud.xxx.eu/fullchain.pem
SSLCertificateKeyFile /etc/letsencrypt/live/cloud.xxx.eu/privkey.pem
</VirtualHost>
</IfModule>

<IfModule mod_ssl.c>
#<VirtualHost *:443>
<VirtualHost *:443 [::]:443>
 ServerName fun.xxx.eu
 ProxyPreserveHost On
# DocumentRoot /opt/emby-server
 ProxyPass /.well-known !
 ProxyPass / http://192.168.1.82:8096/
 ProxyPassReverse / http://192.168.1.82:8096/



Include /etc/letsencrypt/options-ssl-apache.conf
SSLCertificateFile /etc/letsencrypt/live/cloud.xxx.eu/fullchain.pem
SSLCertificateKeyFile /etc/letsencrypt/live/cloud.xxx.eu/privkey.pem
</VirtualHost>
</IfModule>

Weiss nicht ob es wichtig ist, aber noch die ports.config

# If you just change the port or add more ports here, you will likely also
# have to change the VirtualHost statement in
# /etc/apache2/sites-enabled/000-default.conf

#Listen 80

#<IfModule ssl_module>
#	Listen 443
#</IfModule>
#
#<IfModule mod_gnutls.c>
#	Listen 443
#</IfModule>


###########################
# Alte Konfiguration
#Listen [::]:80
#Listen 0.0.0.0:80

#<IfModule ssl_module>
#    Listen [::]:443
#    Listen 0.0.0.0:443
#</IfModule>

#<IfModule mod_gnutls.c>
#    Listen [::]:443
#    Listen 0.0.0.0:443
#</IfModule>


Listen 80 

<IfModule ssl_module> 
    Listen 443 
</IfModule> 

<IfModule mod_gnutls.c> 
    Listen 443 
</IfModule>

Und noch die .htacess

<IfModule mod_headers.c>
  <IfModule mod_setenvif.c>
    <IfModule mod_fcgid.c>
       SetEnvIfNoCase ^Authorization$ "(.+)" XAUTHORIZATION=$1
       RequestHeader set XAuthorization %{XAUTHORIZATION}e env=XAUTHORIZATION
    </IfModule>
    <IfModule mod_proxy_fcgi.c>
       SetEnvIfNoCase Authorization "(.+)" HTTP_AUTHORIZATION=$1
    </IfModule>
    <IfModule mod_lsapi.c>
      SetEnvIfNoCase ^Authorization$ "(.+)" XAUTHORIZATION=$1
      RequestHeader set XAuthorization %{XAUTHORIZATION}e env=XAUTHORIZATION
    </IfModule>
  </IfModule>

  <IfModule mod_env.c>
    # Add security and privacy related headers
    # Avoid doubled headers by unsetting headers in "onsuccess" table,
    # then add headers to "always" table: https://github.com/nextcloud/server/pull/19002

    <If "%{REQUEST_URI} =~ m#/login$#">
      # Only on the login page we need any Origin or Referer header set.
      Header onsuccess unset Referrer-Policy
      Header always set Referrer-Policy "same-origin"
    </If>
    <Else>
      Header onsuccess unset Referrer-Policy
      Header always set Referrer-Policy "no-referrer"
    </Else>

    Header onsuccess unset X-Content-Type-Options
    Header always set X-Content-Type-Options "nosniff"

    Header onsuccess unset X-Frame-Options
    Header always set X-Frame-Options "SAMEORIGIN"

    Header onsuccess unset X-Permitted-Cross-Domain-Policies
    Header always set X-Permitted-Cross-Domain-Policies "none"

    Header onsuccess unset X-Robots-Tag
    Header always set X-Robots-Tag "noindex, nofollow"

    Header onsuccess unset X-XSS-Protection
    Header always set X-XSS-Protection "1; mode=block"

    SetEnv modHeadersAvailable true
  </IfModule>

  # Add cache control for static resources
  <FilesMatch "\.(css|js|mjs|svg|gif|png|jpg|webp|ico|wasm|tflite)$">
    <If "%{QUERY_STRING} =~ /(^|&)v=/">
      Header set Cache-Control "max-age=15778463, immutable"
    </If>
    <Else>
      Header set Cache-Control "max-age=15778463"
    </Else>
  </FilesMatch>

  # Let browsers cache OTF and WOFF files for a week
  <FilesMatch "\.(otf|woff2?)$">
    Header set Cache-Control "max-age=604800"
  </FilesMatch>
</IfModule>

<IfModule mod_php.c>
  php_value mbstring.func_overload 0
  php_value default_charset 'UTF-8'
  php_value output_buffering 0
  <IfModule mod_env.c>
    SetEnv htaccessWorking true
  </IfModule>
</IfModule>

<IfModule mod_mime.c>
  AddType image/svg+xml svg svgz
  AddType application/wasm wasm
  AddEncoding gzip svgz
  # Serve ESM javascript files (.mjs) with correct mime type
  AddType text/javascript js mjs
</IfModule>

<IfModule mod_dir.c>
  DirectoryIndex index.php index.html
</IfModule>

<IfModule pagespeed_module>
  ModPagespeed Off
</IfModule>

<IfModule mod_rewrite.c>
  RewriteEngine on
  RewriteCond %{HTTP_USER_AGENT} DavClnt
  RewriteRule ^$ /remote.php/webdav/ [L,R=302]
  RewriteRule .* - [env=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
  RewriteRule ^\.well-known/carddav /remote.php/dav/ [R=301,L]
  RewriteRule ^\.well-known/caldav /remote.php/dav/ [R=301,L]
  RewriteRule ^remote/(.*) remote.php [QSA,L]
  RewriteRule ^(?:build|tests|config|lib|3rdparty|templates)/.* - [R=404,L]
  RewriteRule ^\.well-known/(?!acme-challenge|pki-validation) /index.php [QSA,L]
  RewriteRule ^ocm-provider/?$ index.php [QSA,L]
  RewriteRule ^(?:\.(?!well-known)|autotest|occ|issue|indie|db_|console).* - [R=404,L]
</IfModule>

# Clients like xDavv5 on Android, or Cyberduck, use chunked requests.
# When FastCGI or FPM is used with apache, requests arrive to Nextcloud without any content.
# This leads to the creation of empty files.
# The following directive will force the problematic requests to be buffered before being forwarded to Nextcloud.
# This way, the "Transfer-Encoding" header is removed, the "Content-Length" header is set, and the request content is proxied to Nextcloud.
# Here are more information about the issue:
#  - https://docs.cyberduck.io/mountainduck/issues/fastcgi/
#  - https://docs.nextcloud.com/server/latest/admin_manual/issues/general_troubleshooting.html#troubleshooting-webdav
<IfModule mod_setenvif.c>
  SetEnvIfNoCase Transfer-Encoding "chunked" proxy-sendcl=1
</IfModule>

# Apache disabled the sending of the server-side content-length header
# in their 2.4.59 patch updated which breaks some use-cases in Nextcloud.
# Setting ap_trust_cgilike_cl allows to bring back the usual behaviour.
# See https://bz.apache.org/bugzilla/show_bug.cgi?id=68973
<IfModule mod_env.c>
  SetEnv ap_trust_cgilike_cl
</IfModule>

AddDefaultCharset utf-8
Options -Indexes
#### DO NOT CHANGE ANYTHING ABOVE THIS LINE ####

ErrorDocument 403 //index.php/error/403
ErrorDocument 404 //index.php/error/404
<IfModule mod_rewrite.c>
  Options -MultiViews
  RewriteRule ^core/js/oc.js$ index.php [PT,E=PATH_INFO:$1]
  RewriteRule ^core/preview.png$ index.php [PT,E=PATH_INFO:$1]
  RewriteCond %{REQUEST_FILENAME} !\.(css|js|mjs|svg|gif|ico|jpg|jpeg|png|webp|html|otf|ttf|woff2?|map|webm|mp4|mp3|ogg|wav|flac|wasm|tflite)$
  RewriteCond %{REQUEST_FILENAME} !/core/ajax/update\.php
  RewriteCond %{REQUEST_FILENAME} !/core/img/(favicon\.ico|manifest\.json)$
  RewriteCond %{REQUEST_FILENAME} !/(cron|public|remote|status)\.php
  RewriteCond %{REQUEST_FILENAME} !/ocs/v(1|2)\.php
  RewriteCond %{REQUEST_FILENAME} !/robots\.txt
  RewriteCond %{REQUEST_FILENAME} !/(ocs-provider|updater)/
  RewriteCond %{REQUEST_URI} !^/\.well-known/(acme-challenge|pki-validation)/.*
  RewriteCond %{REQUEST_FILENAME} !/richdocumentscode(_arm64)?/proxy.php$
  RewriteRule . index.php [PT,E=PATH_INFO:$1]
  RewriteBase /
  <IfModule mod_env.c>
    SetEnv front_controller_active true
    <IfModule mod_dir.c>
      DirectorySlash off
    </IfModule>
  </IfModule>
</IfModule>

Was sagen Webserver und Nextcloud Logs zum Zeitpunkt des Verbindungsabbruchs?
Ich kann mir auch vorstellen, dass fail2ban oder die Bruteforce-App - sofern installiert - die Verbindung wegen “Floodings” blockieren.

vielleicht ist dein Hostsystem auch ĂŒberlastet mit 2 VMs?

Hallo zusammen,

ich denke ich habe den Fehler gefunden.

Es liegt an Crowdsec.
Dieser hat mir gerade meine eigene IP gebannt.
Es hat nur so lange gedauert den Fehler zu finden, da ich es scheinbar geschafft habe zwei Corwdsecs laufen zu lassen. Das gab durcheinannder.
Jetzt ist alles bereinigt und neu eingerichtet.

Also ich rufe aus meinem Heimnetzwerk meine öffentliche URL auf und kurze Zeit spÀter wird meine IP geblockt:

ncadmin@cloud:~$ sudo cscli alerts inspect 4

################################################################################################

 - ID         : 4
 - Date       : 2025-12-09T12:18:19Z
 - Machine    : cc103098eb6c4ed0b5e4be91e1fd488f
 - Simulation : false
 - Reason     : crowdsecurity/http-crawl-non_statics
 - Events Count : 51
 - Scope:Value: Ip:91.60.99.xxx
 - Country    :
 - AS         :
 - Begin      : 2025-12-09 12:18:03.274107185 +0000 UTC
 - End        : 2025-12-09 12:18:19.319065121 +0000 UTC

Die Frage ist, wie verhindere ich das?
Eine Lösung ist wohl die Parameter

leakspeed: 0.5s
capacity: 40

in der /etc/crowdsec/scenarios/http-crawl-non_statics.yaml anzupassen.
Aber was wÀren die richtigen Einstellungen?

Hat jemand einen Rat?

Gruß Helix

Vielleicht helfen die ErlÀuterungen der Einstellungen von Thomas Krenn weiter:

Es wĂŒrde mich nicht wundern, wenn die Zugriffe auf Nextcloud als “Attacke” interpretiert wurden. Ein “richtiger” Umgang mit Crowdsec erfordert wohl einiges an Kenntnissen - so der verlinkte Artikel.

Ich habe die Lösung gefunden.
Es gibt Scripte, die checken per Cronjob regelmĂ€ĂŸig die eigene IP und schreiben diese in eine Whitelist.

Damit sollte es jetzt gehen.

1 Like