Access Nextcloud in HTTPS behind an Apache reverse proxy

Hello
I use a Apache reverse proxy to access my Nextcloud server. In HTTP, it works.
In HTTPS, it does not work and I have the following error:
“# Internal Server Error
The server encountered an internal error or misconfiguration and was unable to complete your request.”
I have a valid Letsencrypt certificate created on the reverse proxy.
Internet-> RevProxy (HTTPS)
RevProxy-> Nextcloud (HTTP)

How do I configure Nextcloud to work?

Part of my “config.php” file
HTTPS streams use 192.168.1.30, http streams 192.168.1.31
A term, Nextcloud should be forced into https.

‘trusted_proxies’ =>
array (
0 => ‘192.168.1.30’,
1 => ‘192.168.1.31’,
),
‘overwrite.cli.url’ => ‘https://nextcloud.jhost.pw’,
‘overwritehost’ => ‘nextcloud.jhost.pw’,
‘overwriteprotocol’ => ‘http’,
‘overwritewebroot’ => ‘’,
‘overwritecondaddr’ => ‘^192.168.1.30$’,

You have 302 redict when using https://nextcloud.jhost.pw. It redirects to http.

If you use https://nextcloud.jhost.pw/index.php/login then there’s no redirection and you’ll see NC mainpage with https.

Thank you for your reply.
I’m not very comfortable with redirects.
At what level should it be corrected
(On the reverse proxy, on the server Nextcloud (htaccess and/or CONFIG. php) ?

I don’t use Apache so I can’t say much about it.
If you post your configs, maybe someone can help.
This guide may be worth of reading if you haven’t. https://www.askapache.com/hosting/reverse-proxy-apache/

Hi MeiRos,

Thank you for your help.
I managed to switch Nextcloud to HTTPS by redirecting all the requests that arrived on port 80 in my reverse proxy.

It works very well now.

<VirtualHost 192.168.1.31:80>
ServerName nextcloud.jhost.pw
ServerAlias www.nextcloud.jhost.pw

Redirect permanent / https://nextcloud.jhost.pw/

ErrorLog /var/log/httpd/scloud-pw80.log
LogLevel debug

Thank you again.

1 Like