Hi! First of all I’m an app developer but I’m new to server development. I currently have this app-server configuration working fine:
iOS/Android app (pro) --> mysubdomain1.domain.com --> Digital Ocean Floating IP --> Droplet #1 (which has a Let’s encrypt certificate associated to mysubdomain1.domain.com).
Now I have a new back-end on a Droplet #2 (more resources than Droplet #1, with more features, same region as Droplet #1 so Floating IP can change between them…). This scenario is working fine too:
iOS/Android app (test) --> mysubdomain2.domain.com --> Droplet #2 (which has a Let’s encrypt certificate associated to mysubdomain2.domain.com).
I would like to know the best (and least risky) way to migrate from the first scenario to the second one (I could make a backup and restore of the back-end database without problems in minutes from one droplet to the other). I guess that this will fail:
iOS/Android app (pro) --> mysubdomain1.domain.com --> Digital Ocean Floating IP (pointing now to the new droplet) --> Droplet #2
I guess this will fail because Let’s encrypt certificate in Droplet #2 is for mysubdomain2.domain.com but connection will be made through mysubdomain1.domain.com.
I was thinking on setting Droplet #2 to mysubdomain1.domain.com too before changing the Floating IP. But I guess this will fail again because Let’s encrypt won’t access Droplet #2 (because mysubdomain1.domain.com points to Droplet #1) and Droplet #2 won’t have the Let’s encrypt certificate.
I wonder if it’s possible to copy the Let’s encrypt certificates from Droplet #1 to Droplet #2 so Droplet #2 supports connections from both subdomains.
So, how could I switch from droplet #1 to droplet #2 in the least risky and easiest way? I’ve read about load balancers and such things but I’m afraid it’s too deep for my server knowledge at the moment.
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.
Hey Ruben,
When I was getting started with my career more than 10 years ago, I used to handle website migrations for different customers as on of my daily tasks.
As long as you plan the migraiton properly it should work out smoothly with minimal downtime.
I will try to cover all of the steps that you need to take, but let me know if you still have any questions:
### 1. Prepare Droplet #2 Before migrating, you’ll want to ensure that Droplet #2 is fully prepared to handle traffic for
mysubdomain1.domain.com
. Here’s how you can do it:mysubdomain1.domain.com
to Droplet #2 in your DNS settings (you can do this by editing the A record).mysubdomain1.domain.com
on Droplet #2. Since DNS propagation might take a little while, you can do this during a low-traffic period to minimize disruption.Make sure that everything on Droplet #2 is set up correctly by accessing
mysubdomain1.domain.com
directly (using a hosts file modification, for example). Test to make sure the SSL certificate is valid and the backend is functioning as expected.Modifying the hosts file on your local machine is a good way to test the site on Droplet #2 without affecting the live site. This file allows you to override DNS for specific domains:
C:\Windows\System32\drivers\etc\hosts
/etc/hosts
Open this file with administrative/root privileges in a text editor. Add a line at the end:
Replace xx.xx.xx.xx with your DigitalOcean Droplet #2 IP address. Save the file and flush your DNS cache. Now, when you visit
mysubdomain1.domain.com
in your browser, it will point to Droplet #2.Once you’re ready to switch, you can remove this line to revert to the original DNS settings.
### 2. Sync Data Between Droplets
Before switching the Floating IP, ensure that all data is synchronized between Droplet #1 and Droplet #2. You mentioned that you can backup and restore the database quickly, so make sure to do this right before the final migration to ensure minimal data loss.
### 3. Switch the Floating IP
Once Droplet #2 is fully ready and you’ve confirmed it’s working with
mysubdomain1.domain.com
, you can now reassign the Floating IP from Droplet #1 to Droplet #2. This change is instantaneous and doesn’t require any DNS propagation, so it minimizes downtime.Keep an eye on the server logs and monitor traffic to ensure that everything is functioning smoothly after the switch. Since the IP address remains the same, users should experience no downtime.
### 4. Handling SSL Certificates
If you’ve followed the earlier steps and issued a new certificate on Droplet #2, you’re all set. The new certificate should automatically be served by Droplet #2 once the Floating IP is pointed to it.
If needed, you can also reissue the Let’s Encrypt certificate on Droplet #2 after the Floating IP switch using the following command:
Alternatively, you can copy the existing Let’s Encrypt certificates from Droplet #1 to Droplet #2 if you prefer not to reissue them. Here’s how: - Copy the full
/etc/letsencrypt/
directory from Droplet #1 to Droplet #2. - Ensure that Nginx or Apache on Droplet #2 is correctly configured to use these certificates. - Reload your web server configuration on Droplet #2.### 5. Post-Migration Cleanup
Once you’ve confirmed that everything is working correctly on Droplet #2, you can either decommission Droplet #1 or keep it as a backup for a short period to ensure stability.
Best of luck with your migration!
- Bobby