Configure to redirect to HTTPS site

I am running apache, and under /etc/apache2/sites-available I have nextcloud.conf. I’ve added the last stanza to re-direct all HTTP traffic to the HTTPS site.
Alias /nextcloud “/var/www/nextcloud/”

<Directory /var/www/nextcloud/>
  Require all granted
  AllowOverride All
  Options FollowSymLinks MultiViews

  <IfModule mod_dav.c>
    Dav off
  </IfModule>

</Directory>

<VirtualHost *:80>
   ServerName 192.168.0.2/nextcloud
   Redirect permanent / https://192.168.0.2/nextcloud
</VirtualHost>

When I visit the HTTP site, it does not re-direct me.

That’s not a server name, it’s a server name (ip address) with a sub directory suffix :wink:

https://cwiki.apache.org/confluence/display/HTTPD/RedirectSSL

@droidus
Some questions for further support:
Do you use on your system 192.168.0.2 only Nextcloud or also another webservice?
Which kind of certificate do you use on 192.168.0.2? Self signed or Lets Encrypt?
Do you want to use DynDNS, Portforwarding, LetsEncrypt for access from the internet?

Nevertheless your config is a bit wrong as @j-ed say. Also as @devnull mentioned you redirect root to the sub path nextcloud in this case all other services if they are will not be accessible anymore.

If you want to access only Nextcloud per LAN IP via https, then simply do:

<VirtualHost *:80>
   ServerName 192.168.0.2

   # Redirects any request from http://192.168.0.2/nextcloud to https
   Redirect permanent /nextcloud https://192.168.0.2/nextcloud

   # Redirects any request from http://192.168.0.2/ to https://192.168.0.2/nextcloud
   # No Other Services will be accessible 
   #Redirect permanent / https://192.168.0.2/nextcloud
 
</VirtualHost>

Here’s a few thoughts to keep in the back of your mind.

No official CA (Certificate Authority) certificate can be issued against an IP address. Only self-signed certs can be issued against IPs. This means you’ll get an error/warning message on every modern browser connecting to your Nextcloud. One warning about the certificate being self-signed, or another for your CA certificate not matching the site name.

Since the IP you’ve specified is LAN-only, it’s completely inaccessible from outside your home network. If you wish for it to be accessible from outside, there are plenty of free domain options to play with to make life easier, and free CA certificates are available from Let’s Encrypt.

Otherwise, I redirect to HTTPS exactly the same way you have! (Except I’m using a domain name.) My vhosts.conf contains:

<VirtualHost *:80>
    ServerName cloud.darksteve.tk
    Redirect permanent / https://cloud.darksteve.tk/
</VirtualHost>

That’s all you need, and it works flawlessly. Just be mindful of the limitations of using IP addresses or self-signed certificates. There’s virtually no mobile apps that will accept a self signed cert.