Carddav service hard to connect behind reverse proxy server

I am having trouble accessing the Nextcloud carddav service via my reverse proxy server. This may be why my Maps app does not work as it should. It is not placing contacts on the map.
The following produces a sane response: curl --user “Fred:Barney” -s -X GET -i
This indicates (to me) that the service does work when the request is sent to the right place. I have created a rewrite rule on the proxy in vhost:

RewriteEngine On
RewriteCond %{HTTP_HOST}
RewriteRule ^.well-known/carddav/(.*)$ https://private IP of cloud server/remote.php/dav/$1 [L,P]

When the same request is made but to etc I get

‘The Document has moved’

Also, strangely, the ‘Location’ is: /remote.php/dav

The double backslash is wrong (it seems to me).

Perhaps there has been a redirect and I need a ProxyPassReverse? Or am I completely barking up the wrong tree?

I’m using Nextcloud Hub 3 (25.0.2); Apache 2.4.55; PHP 8.0.27 on Proxy, 7.4.33 on the Nextcloud server; Contacts 5.0.3 My Nextcloud instance is in the Ubuntu default root /var/www/html/. It is in a folder called nextcloud so the path is /var/www/html/nextcloud. Relevant parts of Nextcloud vhost file are:

  DocumentRoot /var/www/html/nextcloud/
   ServerName private IP of server   
<Directory /var/www/html/nextcloud/>
        Require all granted
        Options FollowSymLinks MultiViews
        AllowOverride All

      <IfModule mod_dav.c>
        Dav off
        Satisfy Any

      <IfModule mod_headers.c>
        Header always set Strict-Transport-Security "max-age=15552000; includeSubDomains"
I don't see why .htaccess in the document root doesn't do the job. I see from the manual that there are problems working behind a reverse proxy but some information why this is would be useful

This seems to work (inside proxy’s vhost file):

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{HTTP_HOST} ^$
RewriteCond %{REQUEST_URI} ^/?\.well-known/carddav(.*)
RewriteRule ^/?\.well-known/carddav/(.*)  https://192.168.x.x/remote.php/dav/$1 [P]
ProxyPassReverse / https://192.168.x.x/

I get appropriate response but sadly it’s not solved my Maps problem.
I guess the Rewrite conditions must be working. I have a number of vhosts on my proxy the conditions are supposed to work only if the request is to and only if the .well-known/carddav appears in the request.