Trying to get HTTPS. Certbot didn't work

I have installed NextCloud on Debian 12 with Apache2 and MariaDB on a computer on my local network. It is up and running, but I cannot find what to do to get HTTPS working. I tried running certbot with letsencrypt, as is typically suggested, but it tells me it won’t make a cert for a bare IP address. I’m unsure what I need to do to give it an address that it will make a cert for.

I have a domain that redirects to the IP address of the nextcloud install, and this has an SSL associated with it, but the secure connection disappears after it redirects. Is it possible to use this domain and SSL? The nextcloud.conf file is not set up as a virtual host, because it would not work when I tried to use that configuration.

If you have a domain, you can use this domain or a subdomain to create a SSL certificate. But you can’t do a manual redirects (webserver 301/302 redirects), it must be a virtual host of you webserver (however it could be a CNAME entry to a dynamic dns name if your ordinary DNS does not support quick updates in case you having changing IP addresses).

If you do a host domain.example.com (nslookup domain.example.com on Windows) it should resolve your current public ip address.