[SOLVED] Downloading publically shared files via /download is very slow (25s vs 300ms)

[SOLVED]
I just figured out why it took so long. I was actually getting rate limited by the anti bruteforce app.
As i have put Nextcloud behind a reverse proxy it was only seeing a local IP address.
I then fixed that by telling nginx to forward the real IP too. But half a year ago I also put sslh infront of nginx to filter out shadowsocks traffic instead of doing it via nginx, as to this day I have not figured out how to do that.
As recently i have been using nextcloud much more, it has gotten lots of traffic and login attempts under the same IP and thats how it ended up rate limiting all requests by accident.
I feel stupid now lol.

Nextcloud version: 26.0.1 & 25.0.6
Operating system and version: Debian GNU/Linux 11 (bullseye) x86_64 Nextcloud on Docker
Apache or nginx version: Tbh, no clue, i don’t know where to check
PHP version: Tbh, no clue, i don’t know where to check

The issue you are facing:
When downloading a shared file via /download it is really slow (25s). When using /preview (on images as example) it downloads at expected speeds (300ms~)

Is this the first time you’ve seen this error? (Y/N):
Yes, I only noticed this very recently. It created errors before on 25.0.6 but after upgrading to 26.0.1 it managed to download the files after some time.

Steps to replicate it:

  1. Upload a file
  2. Share the file
  3. Download it via /download at the end. /preview works fine. I tested it with videos and images

If you want to replicate this on my instance, check out this link:
Slow /download : blackwolfwoof[.]com/s/m4coFBccFx3p6SF/download
Fast /preview : blackwolfwoof[.]com/s/m4coFBccFx3p6SF/preview

More info:

Here a comparison between the speeds / time it took for the same file.


A few ms with /preview and a staggering 25s with /download
The output of your Nextcloud log in Admin > Logging:
This is when i was still on v25.0.6

[no app in context] Error: OC\ForbiddenException: Access denied at <<closure>>

0. /config/www/nextcloud/lib/private/legacy/OC_Files.php line 126
   OC_Files::getSingleFile()
1. /config/www/nextcloud/apps/files_sharing/lib/Controller/ShareController.php line 709
   OC_Files::get()
2. /config/www/nextcloud/lib/private/AppFramework/Http/Dispatcher.php line 225
   OCA\Files_Sharing\Controller\ShareController->downloadShare()
3. /config/www/nextcloud/lib/private/AppFramework/Http/Dispatcher.php line 133
   OC\AppFramework\Http\Dispatcher->executeController()
4. /config/www/nextcloud/lib/private/AppFramework/App.php line 172
   OC\AppFramework\Http\Dispatcher->dispatch()
5. /config/www/nextcloud/lib/private/Route/Router.php line 298
   OC\AppFramework\App::main()
6. /config/www/nextcloud/lib/base.php line 1047
   OC\Route\Router->match()
7. /config/www/nextcloud/index.php line 36
   OC::handleRequest()

GET /s/********/download
from 192.168.160.4 at 2023-04-22T19:14:45+00:00

Full log: Log output nextcloud - Pastebin.com

The output of your config.php file in /path/to/nextcloud:

<?php
$CONFIG = array (
  'memcache.local' => '\\OC\\Memcache\\APCu',
  'datadirectory' => '/data',
  'instanceid' => '************************************',
  'passwordsalt' => '************************************',
  'secret' => '************************************',
  'trusted_domains' =>
  array (
    1 => 'blackwolfwoof.com',
  ),
  'default_phone_region' => 'DE',
  'dbtype' => 'mysql',
  'version' => '26.0.1.1',
  'overwrite.cli.url' => 'https://blackwolfwoof.com/',
  'installed' => true,
  'maintenance' => false,
  'ncd_yt_binary' => '/data/custom_stuff/yt-dlp',
  'dbname' => 'nextcloud',
  'dbhost' => '192.168.178.10:3333',
  'dbuser' => 'root',
  'dbpassword' => '************************************',
  'mysql.utf8mb4' => true,
  'enable_previews' => true,
  'enabledPreviewProviders' =>
  array (
    0 => 'OC\\Preview\\TXT',
    1 => 'OC\\Preview\\MarkDown',
    2 => 'OC\\Preview\\OpenDocument',
    3 => 'OC\\Preview\\PDF',
    4 => 'OC\\Preview\\MSOffice2003',
    5 => 'OC\\Preview\\MSOfficeDoc',
    6 => 'OC\\Preview\\Image',
    7 => 'OC\\Preview\\Photoshop',
    8 => 'OC\\Preview\\TIFF',
    9 => 'OC\\Preview\\SVG',
    10 => 'OC\\Preview\\Font',
    11 => 'OC\\Preview\\MP3',
    12 => 'OC\\Preview\\Movie',
    13 => 'OC\\Preview\\MKV',
    14 => 'OC\\Preview\\MP4',
    15 => 'OC\\Preview\\AVI',
  ),
  'ncd_disable_bt' => '1',
  'mail_smtpmode' => 'smtp',
  'mail_smtpsecure' => 'ssl',
  'mail_sendmailmode' => 'smtp',
  'mail_from_address' => '************************************',
  'mail_domain' => 'gmail.com',
  'mail_smtpauthtype' => 'LOGIN',
  'mail_smtpauth' => 1,
  'mail_smtphost' => 'smtp.gmail.com',
  'mail_smtpport' => '465',
  'mail_smtpname' => '************************************',
  'mail_smtppassword' => '************************************',
  'skeletondirectory' => '',
  'allow_local_remote_servers' => true,
  'theme' => '',
  'loglevel' => 2,
  'onlyoffice' =>
  array (
    'verify_peer_off' => false,
    'jwt_header' => 'AuthorizationJwt',
    'jwt_secret' => '************************************',
  ),
  'app_install_overwrite' =>
  array (
    0 => 'apporder',
    1 => 'impersonate',
    2 => 'cfg_share_links',
    3 => 'files_downloadlimit',
  ),
  'data-fingerprint' => '************************************',
  'updater.secret' => '************************************',
);

The output of your Apache/nginx/system log in /var/log/____:

N/A