Nextcloud version on old/prod system: 18.0.3
PHP: 7.3.16
Apache: 2.4.41
Nextcloud version on new/target system: 18.03 in docker container, image “nextcloud:18.0.3”
Operating system of docker host: Debian 10.3
The issue you are facing:
I am migrating an existing nextcloud-18.0.3 installation from a non-docker installation into a docker-compose stack. That stack runs behind a HAproxy on pfsense … and it works so far.
By “old links should stay valid,” do you mean you want the old URLs to still work and go to the new system? Or they should still access the old Nextcloud?
If you want them to redirect to the new one, that’s easily done by editing the old vhosts and making them redirect clients to the new URL.
The dozens of mail-clients with subscribed calendars etc shouldn’t notice the move to the new system. Over time only the new links will be deployed to them step by step, but we want to keep the old URLs for now.
There will be no parallel 2 installations after migration, no.
So I need
Redirect /nextcloud https://cloud.my.tld
in .htaccess on the new box? Nothing else?
I assume I should remove any of the overwrite_* parameters as well.
(for sure both A-records point to the same machine, I have valid certs installed and the new nextcloud has both names in trusted_domains).
I try that with my test installation and 2 names “mail2” and “cloud”.
Modified .htaccess and reloaded apache.
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{HTTP_USER_AGENT} DavClnt
[..]
RewriteRule ^(?:\.|autotest|occ|issue|indie|db_|console).* - [R=404,L]
# last line here, maybe it should be placed higher?
Redirect "/nextcloud/" "https://cloud.my.tld/"
</IfModule>
I then added a calendar to my thunderbird with URL:
That worked and I could add an event, but then the connection “broke” and I wasn’t able to edit that event anymore. Lightning just tells me to reload as the event has been edited on the server … which isn’t the case IMO. So I can’t edit/write that event anymore.
The nextcloud log doesn’t show any particular error while I try that.
You could try redirecting with a rewrite rule instead of a plain redirect. The difference is that the redirect tells the client to access the new URL. The rewrite rule would simply serve the other site transparently and pretend the URL is still the old one.
The easiest way to do this is probably with pfSense and HAProxy.
You define your new server as a backend (To_Nextcloud).
In your frontend, you put ACLs and Actions for both names to use that same backend :
ACL would be something like :
Old_Name Host matches mail.my.tld
New_Name Host matches cloud.my.tld
Use Backend To_Nextcloud for Old_Name
Use Backend To_Nextcloud for New_Name
For that to work, you need to configure your HAProxy’s IP address as a trusted proxy in config.php. You also need to save there the two valid names to be used for your service.
Be sure you have valid SSL certificates for both names in your HAProxy config.
Sure, I have such a setup already with pfsense, that works!
The open question is that Redirect/Rewrite. I will look into Rewrite instead of Redirect next, as mentionedby @KarlF12
You can also search in your MariaDB for the old values.
Perhaps you can change them with db-manipulations.
Perhaps dumping db, “sed” or other global replace with regular expressions and then restore.
I was able to successfully rewrite the URL with HAproxy.
But Thunderbird/Lightning did not like that very much, to me it seems that some kind of cookie doesn’t match then anymore. I think Lightning expects the calendar object to relate to a cookie with a path containing “/nextcloud” (in my case) and the nextcloud instance writes these cookies with path “/”. This leads to issues, we couldn’t edit the events in Lightning etc
I’d appreciate an explanation of the details!
The solution now is a plain alias in the apache vhost:
Alias /nextcloud /var/www/html
This makes both old and new URLs work with calendars etc
It doesn’t rewrite the URL, but this isn’t priority one here.
People get a new bookmark into their browsers, done.
The main goal was not to break existing DAV-connections.