Trouble making nextcloud available on the Internet

Hello everyone i am having some trouble trying to make my nextcloud available on the internet.I have installed nextcloud successfully and set it so when i enter the server’s ip address i will be presented with the nextcloud login page, my server is a apache2 on a raspberry pi and the conf file i loaded look like this:

/
/ <VirtualHost *:80>
ServerAdmin webmaster@localhost
ServerName example.site
ServerAlias www.example.site
DocumentRoot /var/www/html/nextcloud
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
SSLEngine on
SSLCertificateFile /etc/ssl/certs/ssl-cert-snakeoil.pem
SSLCertificateKeyFile /etc/ssl/private/ssl-cert-snakeoil.key
/
/

In this example a replace my domain name with example.I bought a domain form namecheap and there customer service assured me that my domain records are set correctly,my port fowarding is correct and ddclient is also set up correctly but i still cannot access my site by just typing the domain name in a browser url.Thanks for your help also i have entered the domain in config.php second after the domain of the pi,and the hosts file look like this:(192.168.0.140 ip of the pi)

127.0.0.1 localhost
127.0.1.1 raspberrypi
192.168.0.140 www.example.site example.site

The following lines are desirable for IPv6 capable hosts

::1 localhost ip6-localhost ip6-loopback
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters

And what an error you will see when you open this site?

It does not looks like that this line should be in IPv6 hosts, it should be rather in IPv4 hosts file.

It does not looks like that this line should be in IPv6 hosts, it should be rather in IPv4 hosts file.

your right i corrected know it’s above the IPv6 addresses

And what an error you will see when you open this site?

Page not loading try again later

Simple trouble shooting, I suppose that 192.168.0.140 is internal IP Address of your Nexctloud Server:

  1. From your local Network try to open your webpage direct via IP, e.g. http://192.168.0.140 and https://192.168.0.140. You should be able to see alt least an Trusted domain error (as here). Works? This means you server set correctly to listen on http and https traffic. Go to step 2.

  2. Check that you ports 80 (http) and better 443 (https) are open and you have set correctly your port forwarding.
    For this please find out you external IP, e.g. via Browser https://ipinfo.io/ or run shell command curl ipinfo.io.
    image
    After this take you external IP from the first line and do the call via browser: http://ExternalIPAddr and https://ExternalIPAddr.
    Or you can use online tools to check if ports 80 and 443 are opened: https://www.yougetsignal.com/tools/open-ports/
    If you can again see trusted Domain Error or/and online tools says it open - your port forwarding works fine. Goto step 3.

  3. Check if Domain name bounded to your IP correctly, for this from the Linux Machine simply run command: dig example.site (or use online dig from Google). You will see output something like this:
    image
    Where instead of 216.58.207.78 must be your External IP Address from step 2.

If all 3 steps are successfully done, you must be able to communicate to your server from the internet.

Thanks i failed on the second troubleshooting solution, tried the web site https://www.yougetsignal.com/tools/open-ports/ and found out that port 80 and 443 where closed but when i type curl ipinfo.io i get different ips because am using a dynamic ip e.g when i type it the first time i got 11.111.111.21 and the second time 11.111.111.53 (this are e.g. external ip)

portscreent
This is how i have set my port fowarding

now after you configure your forwarding are the open? Can you pass the test with one of newest IPs?

You have to use some dynamic IP updater, ether on your router you can set it or, e.g. if you are using no-ip.com check this script:
https://github.com/AntonioCS/no-ip.com-bash-updater

Nope there still closed tried another port testing tool www.canyouseeme.org and no luck, even tried nmap -p 80,443 192.168.0.140(pi ip) but get a closed port response is it possible that my ISP may be blocking the ports ?

I’m using ddclient for that and is setup as the domain vendor instructed.

Try to map (in ports forwarding) some other ports, like 4433 or 8080 instead of 80 and 443.

Also if you stays on Point 2, it could be that port forwarding does not work, or your server has kind of IP Whitelisting.
Can you check on your router/modem what is you external IP and call https of it?