Reverse Proxy to Apache to Nextcloud / The port is incorrectly being inserted into the URL

Nextcloud version (eg, 20.0.5): 26.0.2.1
Operating system and version (eg, Ubuntu 20.04): Ubuntu Server; Linux 5.15.0-73-generic x86_64
Apache version (eg, Apache 2.4.25): Apache/2.4.52 (Ubuntu)
NGINX version : Docker NGINX Proxy Manager
PHP version (eg, 7.4): 8.1.2

The issue you are facing:

My structure is this:

Router:443 > NGINX Reverse Proxy > Apache:4432 > Nextcloud

After changing my server’s setup so that an NGINX reverse proxy (in Docker) handles requests, when I enter the Nextcloud URL, I get forwarded to the the port that should be used in the background.

In other words, when I type this: https://nc.myserver.com/nextcloud

It turns my URL to: https://nc.myserver.com:4432/nextcloud/ (which fails to load any page)

Port 4432 is what Apache is listening on. The URL should mask that port and not show it to the end user (me).

Here is a diagram, if it helps communicate my setup:

I discovered that adding a trailing slash to the URL makes it function correctly. The issue is that the Nextcloud clients strip off the trailing slash, so I cannot even work around the problem.

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

Steps to replicate it:

The output of your Nextcloud log in Admin > Logging:

Not sure where this is.

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

<?php
$CONFIG = array (
  'instanceid' => 'my_instance_id',
  'passwordsalt' => 'some_salt_value',
  'secret' => 'some_salt_value',
  'trusted_domains' =>
  array (
    0 => 'myservername.local',
    1 => '192.168.1.16',
    2 => 'nc.myservername.com',
  ),
  'datadirectory' => '/var/nextcloud-data/',
  'dbtype' => 'mysql',
  'version' => '26.0.2.1',
  'overwriteprotocol' => 'https',
  'dbname' => 'nextcloud',
  'dbhost' => 'localhost',
  'dbport' => '',
  'dbtableprefix' => 'oc_',
  'mysql.utf8mb4' => true,
  'dbuser' => 'ncloud-svc',
  'dbpassword' => 'db_password',
  'installed' => true,
  'memcache.local' => '\\OC\\Memcache\\Redis',
  'default_phone_region' => 'US',
  'maintenance' => false,
  'mail_smtpmode' => 'smtp',
  'mail_sendmailmode' => 'smtp',
  'mail_smtpport' => '587',
  'mail_from_address' => 'private',
  'mail_domain' => 'private',
  'mail_smtpauth' => 1,
  'mail_smtpname' => '',
  'mail_smtppassword' => '',
  'mail_smtpauthtype' => 'LOGIN',
  'app_install_overwrite' =>
  array (
    0 => 'nextant',
    1 => 'files_fulltextsearch_tesseract',
    2 => 'joplin',
    3 => 'extract',
  ),
  'theme' => '',
  'loglevel' => 3,
  'has_rebuilt_cache' => true,
  'memories.exiftool' => '/var/www/html/nextcloud/apps/memories/exiftool-bin/exiftool-amd64-glibc',
  'memories.ffmpeg_path' => '/usr/bin/ffmpeg',
  'memories.ffprobe_path' => '/usr/bin/ffprobe',
  'memories.transcoder' => '/var/www/html/nextcloud/apps/memories/exiftool-bin/go-vod-amd64',
  'memories.no_transcode' => false,
  'memories.qsv' => false,
  'memories.gis_type' => 1,
  'memories.vod.path' => '/var/www/html/nextcloud/apps/memories/exiftool-bin/go-vod-amd64',
  'memories.vod.ffmpeg' => '/usr/bin/ffmpeg',
  'memories.vod.ffprobe' => '/usr/bin/ffprobe',
  'overwrite.cli.url' => 'https://nc.myserver.com/nextcloud/',
  'overwritewebroot' => '/nextcloud',
  'overwritehost' => 'nc.myserver.com:443',
);

hi @TidyBeach welcome to the forum :handshake:

very nice first post! very clear problem description and good visio showing the architecture!

I’m missing right reverse proxy settings like overwritehostand overwrite.cli.url and likely trusted_proxies. Take a look at the docs and tell us and share the logs if the issue remains after you adopt your config.

Not related to your problem - but I would not mix docker and bare-metal… for Docker good “standard” images exist and AIO which is very nice and simple Docker based full-blown Nextcloud setup…

1 Like

ah shoot, I forgot to get the rest of that config text. I just grabbed it and pasted it in there. I think I tried with and without the trailing slash on the overwrite.cli.url, but currently it’s there.

I did try switching over to nextcloud in docker but it was very laggy, so I just kept my original installation. If there’s a way to speed it up, I wouldn’t mind switching to docker, but it didn’t seem like it would work out when I tried it. Of course, it’s not working out now either. :joy:

you don’t need :443 - but seems not to be a reason for the problem. For me the config looks right now.

  • try to find out where the redirection comes from using F12 browser tools.
  • Maybe there is some cache problem if you didn’t configure system right from the beginning verify if the issue exists as well using incognito/private tab.

Docker itself doesn’t really add an overhead so Docker based application should be as fast as native install. Don’t forget to add redis container and real database. or try AiO as I recommended above.

1 Like

I have given up on the original setup that was failing. I’m sure there was some way to make it work but I couldn’t get it.

I switched over to a docker setup, as you recommended. Interestingly, the AIO setup was having issues, but there was a docker stack that I tried and is now working well. Maybe it’s not any more laggy as I originally thought.

I do have an issue with the OCR, but I’ll open up a new thread to ask about that.

Thank you for your help.

What kind of issue did it have?