Internal link dosent redirect to login, 403 forbidden

Hello all,

Nextcloud version: 26.0.1 - 26.0.1.1
Operating system and version : Ubuntu 22.04.2 LTS
Apache or nginx version: Apache/2.4.56
PHP version: 8.1.18

The issue you are facing:

we’ve got a problem with our nextcloud instance, while trying to open an “internal link” the user can’t reach the login page but only sees a “403 forbidden” page.

This only happens on internal links:

  • eg.: httxs://cloud.something.tld/f/1234, which gets redirected to httxs://cloud.something.tld/login?redirect_url=/f/1234

External links are working just fine:

  • eg.: httxs://cloud.something.tld/s/aSdBg7Hu8B

Links to other apps or settings are also working:

  • eg.: httxs://cloud.something.tld/settings/admin/overview, which gets redirected to httxs://cloud.something.tld/login?redirect_url=/settings/admin/overview

If I replace the “httxs://cloud.something.tld/f/1234” with “httxs://cloud.something.tld/index.php/f/1234” (which will become “httxs://cloud.something.tld/login?redirect_url=/index.php/f/1234”) everything works as expected and the user is redirected to the login page.

Our setup is dockerized with the Nginx Proxy Manager in front, but we can’t find anything in the logs of docker or NPM either.

Is this the first time you’ve seen this error?: Yes

Steps to replicate it:

  1. Create an internal link to a file
  2. Log out
  3. Open the link

The output of your Nextcloud log in Admin > Logging:

nothing

The output of your config.php file in /path/to/nextcloud (make sure you remove any identifiable information!):

<?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,
  ),
  'overwritehost' => '********',
  'overwriteprotocol' => 'https',
  'passwordsalt' => '********',
  'secret' => '********',
  'trusted_domains' =>
  array (
    0 => 'localhost',
    1 => '********',
  ),
  'datadirectory' => '/var/www/html/data',
  'skeletondirectory' => '',
  'dbtype' => 'pgsql',
 'version' => '26.0.1.1',
  'overwrite.cli.url' => '********',
  'dbname' => '********',
  'dbhost' => '********',
  'dbport' => '',
  'dbtableprefix' => '********',
  'dbuser' => '********',
  'dbpassword' => '********',
  'installed' => true,
  'instanceid' => '********',
  'mail_smtpmode' => 'smtp',
  'mail_sendmailmode' => 'smtp',
  'mail_smtpsecure' => 'tls',
  'mail_smtphost' => '********',
  'mail_smtpport' => '********',
  'mail_smtpauthtype' => 'LOGIN',
  'mail_smtpauth' => 1,
  'mail_smtpname' => '********',
  'mail_smtppassword' => '********',
  'mail_from_address' => '********',
  'mail_domain' => '********',
  'default_phone_region' => 'DE',
  'defaultapp' => 'files',
  'loglevel' => 2,
  'maintenance' => false,
);

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

[12/May/2023:14:11:44 +0000] "GET /f/8554 HTTP/1.1" 303 1650 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:109.0) Gecko/20100101 Firefox/113.0"

[12/May/2023:14:11:44 +0000] "GET /favicon.ico HTTP/1.1" 404 8190 "https://cloud.something.tld/login?redirect_url=/f/8554" "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:109.0) Gecko/20100101 Firefox/113.0"


1 Like

You’re using a reverse proxy, but haven’t setup NC to be behind one. You need to set your trusted_proxies parameter:

https://docs.nextcloud.com/server/stable/admin_manual/configuration_server/reverse_proxy_configuration.html

There could also be additional bits, but that’s a start.

Thanks for this detail!
I’ve added the proxy host ip and restarted the redis container.

But unfortunately that didn’t changed anything (as far as I can tell).

The NPM is on the same host (also dockerized) as NC and we don’t have any other (known) problems except for the internal links.

1 Like

I have the same setup as you running nextcloud in a docker with NPM as my reverse proxy and also am running into this same issue with hitting the 403 error on internal share links when the user clicks the link and is not logged in.

Just ran into this issue today and noticed this post being 3 days old. Haven’t found much of an answer search the web as of yet.

1 Like

There’s also another person with the same problem:

1 Like

See here. Someone came by and solved this for me:

You need to disable “Block common exploits”.