No access via local network with 'overwriteprotocol' => 'https',

Hello everyone,

i just did a fresh install of nextcloud on a proxmox lxc behind an apache reverse proxy. I managed to access nextcloud locally and via the internet.

Now i wanted to install the nextcloud linux client on my pc, but i couldn’t grant the client access to my server. I read that i could solve the problem by adding the line

'overwriteprotocol' => 'https',

to the config.php file. If I do this it indeed works, but then I can’t access the nextcloud server directly over it’s local ip address anymore. I guess it’s because the server expects a https-request but i try to access it via a http-request.

So how can i solve this problem?

Here’s my config.php

<?php
$CONFIG = array (
  'trusted_domains' => 
  array (
    0 => 'cloud.local',
    1 => '192.168.0.99',
    2 => 'mydomain.org',
  ),
  'datadirectory' => '/mnt/hdd/data/',
  'dbtype' => 'mysql',
  'version' => '19.0.0.12',
  'overwrite.cli.url' => 'http://cloud.local',
  'overwriteprotocol' => 'https',
  'dbname' => '',
  'dbhost' => '',
  'dbport' => '',
  'dbtableprefix' => 'oc_',
  'mysql.utf8mb4' => true,
  'dbuser' => '',
  'dbpassword' => '',
  'installed' => true,
  'htaccess.RewriteBase' => '/',
);

And the .conf file of the reverse proxy

<VirtualHost *:80>
 ServerName mydomain.org
 ProxyPreserveHost On
 DocumentRoot /var/www/html
 ProxyPass /.well-known !
 ProxyPass / http://192.168.0.99:80/
 ProxyPassReverse / http://192.168.0.99:80/
RewriteEngine on
RewriteCond %{SERVER_NAME} =mydomain.org
RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]
</VirtualHost>

@Mackes-sys you can see my answer here: Some HTTP links not rewritten to HTTPS despite `'overwriteprotocol' => 'https'`

To clarify. Can you not use the public domain name for your local access? I just added my local ip to my DNS. You can also add in hosts file. That way the TLS certificate is correct.

Hi thanks for your answer, but I’m not sure if i understand this correctly…

So the suggestion is changing the last three lines in the .conf file of my proxy to

RewriteEngine On
RewriteCond %{HTTPS} off
RewriteCond %{REQUEST_URI} !^/.well-known
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [NC,NE,R=permanent,L]

and removing the line

'overwriteprotocol' => 'https'

?
I think i can just use my domain for the local access, can you explain that a bit more in detail? Which hosts file do i have to edit and how exactly?

sorry if this question is trivial, but this is the first server I’m setting up

Okay I already figured it out, i added my server to the hosts file now everything works fine

Thank you

Could you please post your hosts file contains
Im have same problem