[Warning] The reverse proxy header configuration is incorrect, or you are accessing Nextcloud from a trusted proxy

Support intro

Sorry to hear you’re facing problems :slightly_frowning_face:

help.nextcloud.com is for home/non-enterprise users. If you’re running a business, paid support can be accessed via portal.nextcloud.com where we can ensure your business keeps running smoothly.

In order to help you as quickly as possible, before clicking Create Topic please provide as much of the below as you can. Feel free to use a pastebin service for logs, otherwise either indent short log examples with four spaces:

example

Or for longer, use three backticks above and below the code snippet:

longer
example
here

Some or all of the below information will be requested if it isn’t supplied; for fastest response please provide as much as you can :heart:

Nextcloud version (eg, 20.0.5): 27.0.1
Operating system and version (eg, Ubuntu 20.04): (Ubuntu 23.04 64bit / Linux 6.2.0-25-generic)
Apache or nginx version (eg, Apache 2.4.25): 1.24.0
PHP version (eg, 7.4): 8.2.8
Docker version: 24.0.4, build 3713ee1
Reverse Proxy: a Swag container running on the same box.

The issue you are facing:

In the WebUI, Administration->Security & setup warnings, there is a warning read as following:
* The reverse proxy header configuration is incorrect, or you are accessing Nextcloud from a trusted proxy. If not, this is a security issue and can allow an attacker to spoof their IP address as visible to the Nextcloud. Further information can be found in the documentation ↗.

Is this the first time you’ve seen this error? (Y/N): Y

Steps to replicate it:

  1. Open the URI of the Nextcloud instance
  2. open a menu by click on profile avatar
  3. click on the Administration

The output of your Nextcloud log in Admin > Logging:

{"reqId":"ViYZrgbcR4DUZ7ul4EOL","level":3,"time":"2023-07-23T15:27:29+00:00","remoteAddr":"","user":"--","app":"PHP","method":"","url":"--","message":"foreach() argument must be of type array|object, null given at /config/www/nextcloud/apps/files_excludedirs/lib/Wrapper/Exclude.php#78","userAgent":"--","version":"27.0.1.2","data":{"app":"PHP"},"id":"64bd490c76e35"}

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

<?php
$CONFIG = array (
  'memcache.local' => '\\OC\\Memcache\\APCu',
  'datadirectory' => '/data',
  'instanceid' => '[omitted]',
  'passwordsalt' => '[omitted]',
  'secret' => '[omitted]',
  'trusted_domains' => 
  array (
    0 => '[omitted]',
    1 => '[omitted]',
    2 => '[omitted]',
    3 => '[omitted]',
    4 => '10.27.0.50',
  ),
  'dbtype' => 'mysql',
  'version' => '27.0.1.2',
  'trusted_proxies' => 
  array (
    0 => '192.168.1.1',
    1 => 'localhost',
    2 => '::1',
    3 => '10.27.0.50',
  ),
  'overwrite.cli.url' => '[omitted]',
  'overwritehost' => '[omitted]',
  'overwriteprotocol' => 'https',
  'dbname' => 'nextcloud',
  'dbhost' => 'mariadb:3306',
  'dbport' => '',
  'dbtableprefix' => 'oc_',
  'mysql.utf8mb4' => true,
  'dbuser' => '[omitted]',
  'dbpassword' => '[omitted]',
  'installed' => true,
  'default_phone_region' => 'GB',
  'memcache.distributed' => '\\OC\\Memcache\\Redis',
  'memcache.locking' => '\\OC\\Memcache\\Redis',
  'redis' => 
  array (
    'host' => 'redis',
    'port' => 6379,
    'timeout' => 1.5,
  ),
  'preview_max_x' => NULL,
  'preview_max_y' => NULL,
  'jpeg_quality' => '80',
  'preview_max_scale_factor' => 1,
  'enabledPreviewProviders' => 
  array (
    0 => 'OC\\Preview\\MP3',
    1 => 'OC\\Preview\\TXT',
    2 => 'OC\\Preview\\MarkDown',
    3 => 'OC\\Preview\\OpenDocument',
    4 => 'OC\\Preview\\Krita',
    5 => 'OC\\Preview\\Imaginary',
  ),
  'preview_imaginary_url' => 'http://imaginary:9000',
  'app_install_overwrite' => 
  array (
    0 => 'files_excludedirs',
  ),
  'mail_smtpmode' => 'smtp',
  'mail_smtpsecure' => 'tls',
  'mail_sendmailmode' => 'smtp',
  'mail_from_address' => '[omitted]',
  'mail_domain' => '[omitted]',
  'mail_smtpauthtype' => 'LOGIN',
  'mail_smtpauth' => 1,
  'mail_smtphost' => 'smtp.gmail.com',
  'mail_smtpport' => '587',
  'mail_smtpname' => '[omitted]',
  'mail_smtppassword' => '[omitted]',
  'maintenance' => false,
  'loglevel' => 2,
  'theme' => '',
  'filelocking.enabled' => 'true',
);

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

error.log is empty

Output errors in nextcloud.log in /var/www/ or as admin user in top right menu, filtering for errors. Use a pastebin service if necessary.
The file is way too big. The last 200 lines are shown here.
nextcloud.log

If you have your reverse proxy configuration correct, trusted_proxies is not actually required. Try taking it out. It worked for me.

1 Like

thank you for suggesting this, I have been pulling my hair out all night about this error.