If the visitors access to incorrect prefix, then the web server will return the 403. The web server configurations are not the problems to me, but I need to know how to configure the nextclound’s config.php for this. And also how to configure this prefix to the Nextcloud Android App.
I found the solution according to Nextcloud’s official manuals.
To add a URL prefix for an existing Nextcloud installation, one should do following steps:
1: Configure the HTTP server of the existing Nextcloud installation.
Change the DocumentRoot to a dummy directory and add restrictions to the dummy directory as deny all requests.
Then add an Alias to the wanted prefix to the real directory of the existing Nextcloud installation (which should be the original DocumentRoot).
#DocumentRoot /Org/Install/Dir/
DocumentRoot /Dummy/Dir/
<Directory "/Dummy/Dir/">
Require all denied
</Directory>
Alias "/My/Wanted/Prefix/" "/Org/Install/Dir/"
Then restart the HTTP server. And as you know, my example here is for Apache web server.
2: Configure Nextcloud’s config.php
Find the line below: 'overwrite.cli.url' => '',
change to 'overwrite.cli.url' => 'https://mycloud.example.com/My/Wanted/Prefix',
3: Configure Nextcloud Android App
Actually , I can find no way to change the existing login of the Nextcloud Android App. I managed to uninstall the Nextcloud Android App then install it back to begin the login process. Maybe there are smarter methods like delete cache and local storage etc.
Anyway, at the login place you should choose the private installation and at the URL field fill up the URL as https://mycloud.example.com/My/Wanted/Prefix
Using the docker image since I am using an old mac as my server, but when I do this every page returns a 403. This is what I did in the apache site config:
# DocumentRoot /var/www/html
DocumentRoot /Dummy/Dir/
<Directory "/Dummy/Dir/">
Require all denied
</Directory>
Alias "/nextcloud/" "/var/www/html/"