Proxy/RewriteBase problem while transforming old installation into Docker

Hello, NC community.

I’m transferring a very outdated installation (Nextcloud 21 on an outdated Raspbian in a RaspberryPi) into a new server, which is a Debian VM where I’m trying to install Nextcloud using Docker.

I can successfully load the database into the MariaDB container, mount the old Nextcloud folder (from /var/www/nextcloud in the old rpi) and update it by following this guide Notes on migrating Nextcloud to docker with version mismatch – Code Make Share

My user works and the files are all there, so that part is successfully working.

The problem, however, is that in the old rpi I set up a VirtualHost in Apache so that the clients access with a URL like https://example.com/nextcloud, which I can’t replicate in the Docker installation, so right now I’m accessing Nextcloud using just the Debian machine IP.

I’ve tried setting up an Nginx reverse proxy, but I’m still learning this kind of server administration and I haven’t been able to do it yet.

I’ve also tried messing with “htaccess.RewriteBase”, “overwritewebroot” and those kind of things, but I can’t manage to get them working.

So, can I do what I need using only the nextcloud-apache image in Docker? Or do I 100% need to set up a proxy somehow?

If I have to setup a proxy, could you point me in the right direction?

Also, maybe not exactly related and maybe not Nextcloud related, but after setting up the proxy I will need to transfer the certbot configuration from the rpi to the Debian. I’m not sure if this is completely independent from Nextcloud and the proxy, but just in case, will the certificate configuration be hard to get working with this setup?

Thank you in advance.

Nextcloud version (eg, 20.0.5): 28 (from Docker)
Operating system and version (eg, Ubuntu 20.04): Debian 12 (bookworm)
Apache or nginx version (eg, Apache 2.4.25): Apache (whatever Docker uses)
PHP version (eg, 7.4): whatever Docker uses