I have scowered the web, but cannot find this particular redirection issue

HTTPS redirection to HTTP no matter what I do

I have recently been tasked with repairing a SSL issue on a site that I am managing, the SSL issue is not an Apache issue, as the redirection is coming from HTaccess, or something else in the code of Nextcloud.
I have put this in the htaccess file:

RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R,L]

Which instantly fails with a too many redirections in chrome.

When it is disabled, the site instantly works on http.

Everything else

Nextcloud version (eg, 18.0.2): 19.0.4
Operating system and version (eg, Ubuntu 20.04): Ubuntu 18.04 (Fully updated)
Apache or nginx version (eg, Apache 2.4.25): (Apache2 Fully Updated)
PHP version (eg, 7.1): PHP 7.2.24-0ubuntu0.18.04.7

The issue you are facing:

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

Steps to replicate it:

  1. Enabled SSL anywhere in apache, or Nextcloud.
  2. Page instantly fails to load.

The output of your Nextcloud log in Admin > Logging:

Nothing of relevance? 
When looking through it was curl issues about being loaded at unknown#0
Error	PHP	Module 'curl' already loaded at Unknown#0

and others

Error	no app in context	Symfony\Component\Routing\Exception\RouteNotFoundException: Unable to generate a URL for the named route "theming.Theming.getImage" as such route does not exist.		2020-10-19T10:44:13-0600
Error	no app in context	Symfony\Component\Routing\Exception\RouteNotFoundException: Unable to generate a URL for the named route "photos.page.index" as such route does not exist.		2020-10-19T10:44:13-0600

The output of your config.php file in /path/to/nextcloud (Replaced Identifiable data with NAH):

<?php
$CONFIG = array (
  'instanceid' => 'NAH',
  'passwordsalt' => 'NAH',
  'secret' => 'NAH',
  'trusted_domains' =>
  array (
    0 => 'files.NAH.ca',
    1 => 'nextcloud.NAH.ca',
  ),
  'datadirectory' => '/home/NAH/public_html/data',
  'dbtype' => 'mysql',
  'version' => '19.0.4.2',
  'overwrite.cli.url' => 'https://files.NAH.ca',
  'dbname' => 'filesNAHca',
  'dbhost' => 'NAH:3306',
  'dbport' => '',
  'dbtableprefix' => 'oc_',
  'mysql.utf8mb4' => true,
  'dbuser' => 'files.NAH.ca',
  'dbpassword' => 'NAH',
  'installed' => true,
  'skeletondirectory' => '',
  'mail_smtpmode' => 'smtp',
  'mail_sendmailmode' => 'smtp',
  'twofactor_enforced' => 'false',
  'twofactor_enforced_groups' =>
  array (
    0 => 'admin',
  ),
  'twofactor_enforced_excluded_groups' =>
  array (
  ),
  'maintenance' => false,
  'theme' => '',
  'loglevel' => 2,
  'mail_from_address' => 'NAH',
  'mail_domain' => 'NAH.ca',
  'mail_smtphost' => 'smtp-relay.gmail.com',
  'mail_smtpport' => '587',
  'mail_smtpsecure' => 'tls',
  'updater.secret' => 'NAH',
);

The output of your Apache log in /var/log/____: (Basically 1000’s of these lines.)

[19/Oct/2020:10:23:31 -0600] "GET //index.php/login?clear=1 HTTP/1.1" 302 709 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.75 Safari/537.36"

Hello friend, hope you are doing well…

To help you with this, I’d like to have some extra info about the case.

1: Did you check your CA’s, are they still valid?
2: Do you have a bough certificate or you generated a valid one?
3: Are you sure you use SSL and not TLS?
4: Do you an older backup (in the time that your application used to work normally) from that .htaccess file?

As soon as you reply me, I’ll try to help.

Good luck!

:smiley: