HTTPS access nextcloud public ip adress doesn't work

Hello Guys i have a problem with https. When I open nextcloud with http local ip or public ip it works, https local ip adres it work but when I try to open it with https public ip it doens’t work. My configuration

1
sudo nano /etc/apache2/apache2.conf
<Directory /var/www/>
Options Indexes FollowSymLinks
AllowOverride None
Require all granted

changed too
<Directory /var/www/>
Options Indexes FollowSymLinks
AllowOverride All
Require all granted

2
sudo mkdir -p /etc/apache2/ssl
sudo openssl req -x509 -nodes -days 365 -newkey rsa:4096 -keyout /etc/apache2/ssl/apache.key -out /etc/apache2/ssl/apache.crt

3
Country Name (2 letter code) [AU]: pressed enter
State or Province Name (full name) [Some-State]: pressed enter
Locality Name (eg, city) []: pressed enter
Organization Name (eg, company) [Internet Widgits Pty Ltd]: pressed enter
Organizational Unit Name (eg, section) []: pressed enter
Common Name (e.g. server FQDN or YOUR name) []: pressed enter
Email Address []: pressed enter

4
sudo a2enmod ssl
sudo nano /etc/apache2/sites-available/default-ssl.conf

5
SSLCertificateFile /etc/ssl/certs/ssl-cert-snakeoil.pem
SSLCertificateKeyFile /etc/ssl/private/ssl-cert-snakeoil.key
change to
SSLCertificateFile /etc/apache2/ssl/apache.crt
SSLCertificateKeyFile /etc/apache2/ssl/apache.key

6
sudo a2ensite default-ssl.conf
sudo service apache2 restart

7
sudo nano /etc/apache2/sites-available/000-default.conf
delete everything and added
<VirtualHost :80>
ServerAdmin example@example
DocumentRoot /var/www/html
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule ^(.
)$ https://%{HTTP_HOST}$1 [R=301,L]

8
sudo a2enmod rewrite
sudo service apache2 restart

9
sudo nano /var/www/html/nextcloud/config/config.php
’trusted_domains’ =>
array (
0 => ‘192.168.2.20’,
1 => ‘public ip adress’,
3 => ‘public ip adress phone network’,
),
settings:

/var/www/html/nextcloud/config/config.php
overwrite.cli.url => http://192.168.2.20/nextcloud
dbtype mysql
version 12.0.3.3

I installed nextcloud in /var/www/html/nextcloud

portforwarded on my router 443 and 80

when I delete see below http connection nextcloud from public IP works
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}$1 [R=301,L]

How can I fix it that nextcloud is access able from my public IP adress on https. I tried many things changed overwrite.cli.url from http to https. Changed inside 000-defaults.conf many things.

isn’t that supposed to be <VirtualHost ip_or_*:443>

Since you created a snakeoil cert, why not just leave the snakeoil in? You will get a certificate error anyways when you browse to it, but i guess (hope) you are just testing and figuring things out.

If you can https browse it from LAN but not from WAN i´m 100% certain, that the problem doesn’t lie within your nextcloud server or webserver config, but on your router/firewall or somewhere else outside your NC Server.

@Ascendancer
Can you access the default index file of webserver root via https from outside network? What message does browser show?
Perhaps also webserver log provides hints.

Common Name (e.g. server FQDN or YOUR name) []: pressed enter

Did you enter public IP/domain there? At least otherwise this would produce browser warnings.

@pieter
443 is given in default-ssl.conf, 000-default is the correct 80 vhost that just provides the redirection.

Thanks you guys the problem was my firewall 443 was restricted i changed it to 8443