Problem accessing Nextcloud from behind a reverse proxy server

Hello, I am running Ubuntu Server 21.10 in a Hyper-V machine with Windows Server 2022 as the host system. This host server is one of several I have behind my router, so I have no choice but to use a reverse proxy to get to my Nextcloud installation. I should also add that I installed Nextcloud on the Ubuntu server using snap.

Here’s my problem, I can access the Nextcloud installation from my domain name (example.com) to get to the “Access through untrusted domain” page, but for some reason as soon as I add my IP address to the list of trusted domains, I get a 500 - Internal server error.

Any help with this would be greatly appreciated, I have already spent days trying to get this Nextcloud installation up and running. Thanks for your time.

You will need to add your reverse proxy to the trusted domain in Nextcloud config.php.

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

2 Likes

Thank you for your response, I hadn’t thought about adding a trusted proxy. So I had added the proxy IP address to the list of trusted domains already, but from what I understand I need to add it to the list of trusted proxies. I know the link you gave me describes how to do this, but I suck with php. This is what I have added in the config.php file, but it doesn’t seam to work. Any ideas?

<?php
$CONFIG = array (
  'trusted_proxies' => '192.168.2.2',        **<---This is the only line I added**
  'apps_paths' =>
  array (
    0 =>
    array (
      'path' => '/snap/nextcloud/current/htdocs/apps',
      'url' => '/apps',
      'writable' => false,
    ),
    1 =>
    array (
      'path' => '/var/snap/nextcloud/current/nextcloud/extra-apps',
      'url' => '/extra-apps',
      'writable' => true,
    ),
  ),
  'supportedDatabases' =>
  array (
    0 => 'mysql',
  ),
  'memcache.locking' => '\\OC\\Memcache\\Redis',
  'memcache.local' => '\\OC\\Memcache\\Redis',
  'redis' =>
  array (
    'host' => '/tmp/sockets/redis.sock',
    'port' => 0,
  ),
  'log_type' => 'file',
  'logfile' => '/var/snap/nextcloud/current/logs/nextcloud.log',
  'logfilemode' => 416,
  'instanceid' => 'ocorkmrneall',
  'passwordsalt' => '96HOW3vfmVWqKs36OKBvHBKodQgddY',
  'secret' => '6bTJrze4ttg63abZW4CteNdxawtUJryfQKqL6kFu8VOrZGWN',
  'trusted_domains' =>
  array (
    0 => 'localhost',

If this will help, these are my settings. I have my server behind a Nginx Reverse Proxy server but the concept is still the same.

‘trusted_domains’ =>
array (
0 => ‘Domain Name’,
1 => ‘Nextcloud Server IP’,
2 => ‘Reverse Proxy Server IP’,
),
‘trusted_proxies’ => ‘Reverse Proxy Server IP’,
‘overwriteprotocol’ => ‘https’,
‘overwritehost’ => ‘Domain Name’,
‘overwritecondaddr’ => ‘^00\.00\.000\.00$’, <---- This is the reverse proxy IP broken down.
‘forwarded-for-headers’ =>
array (
0 => ‘X-Forwarded-For’,
1 => ‘HTTP_X_FORWARDED_FOR’,
),
‘overwrite.cli.url’ => ‘https://Domain Name/nextcloud’,

1 Like

I am trying to set it up right now, I don’t understand this part. So lets say my reverse proxy server IP is 123.123.1.1 would I change this value to ‘^000.000.0.0$’

I got it figured out, finally! Alright, for anyone else running into this problem, my fix was everything cyberjohn58 had to say (thanks again, that was a big help) as well as this fix from RockNLol that
has to do with forcing NC to send out uncompressed data.

Thank you both for saving me an untold amount of time.

1 Like

‘trusted_domains’ =>
array (
0 => ‘Domain Name’,
1 => ‘192.168.2.2’,
2 => ‘123.123.1.1’,
),
‘trusted_proxies’ => [‘123.123.1.1’],
‘overwriteprotocol’ => ‘https’,
‘overwritehost’ => ‘Domain Name’,
‘overwritecondaddr’ => ‘^123\.123\.1\.1$’,

1 Like

The above ‘condensed’ April 22 solution offered by cyberhohn58 worked for me as well. Running NC on a Proxmox server, using the Turnkey LXC container NC template.