Testing a server moved to a new host
There are several reasons you might want to move to a new VM, but the most common is that the OS on the old one is beyond end of life. The way that Literate Computing likes to do this is very similar to Move a Discourse site to another VPS with rsync - Self-Hosting - Discourse Meta. In short, you copy the Discourse data and configuration files (from /var/discourse/shared
and /var/discourse/containers
respectively) and run a good old ./launcher rebuild app
).
If you like to play fast and loose, you can then just update your DNS (or change a Digital Ocean “Reserved IP” to point to the new server), but maybe you’d like to have a look at things before everyone else does. In the old days, you might just type the IP address of the new server into your browser and had a look around. Today, though, everything requires https, so the IP address will just redirect you to the hostname, which takes you to the old site. What you need to do now, is change your computer so accessing the hostname takes you to the new server rather than the one that is returned by the DNS servers.
Before you do this, take note! If you make these changes so that your computer sees one server when you enter your hostname and everyone else in the world sees the old one and then forget about it, you are going to be very, very confused. If you do this, you should do something to ensure that if the phone rings or you need another cup of coffee, you don’t forget to un-do these changes!
Here’s how to do it.
On Linux
nano /etc/hosts
Add a line like:
192.168.1.1 newserver.myforum.us
The DNS cache needs to be flushed after every change:
sudo resolvectl flush-caches
On a Mac
From: macos - Where can I force a specific DNS server to be used on OS X? - Super User
sudo nano /private/etc/hosts
Add a line like:
192.168.1.1 newserver.myforum.us
The DNS cache needs to be flushed after every change:
dscacheutil -flushcache
I don’t have a Windows computer and didn’t like any of the suggestions that I saw when I searched “windows override dns for single host”. Maybe you’ll have better luck.