📚 Encyclopedia

Servers & Hosting · updated 2026-10-26

Moving a website to a new server without downtime

migrationdnsttlcertbotlets-encryptreverse-proxyapachenginxold-server

Moving a site from an old server to a new one has an awkward middle period: the new server is ready but DNS still points at the old one, and DNS changes take up to a full TTL to reach everyone. The trick is to make the old server forward to the new one during that window, so it does not matter which address a visitor's resolver has cached. The same forwarding lets the new server get its TLS certificate before DNS moves. Worked example: justinandrewhampton.com, moved from the CentOS 7 old server (45.79.19.71) to the Alma 9 server (45.79.9.71) on 2026-10-22.

Steps

  1. Inventory and audit the old site before copying it. Copy the docroot into a git repo, then read every executable file. Drop whatever is not needed: a static page with an empty PHP block can become plain HTML and stop needing PHP at all.
  2. Do not carry over secrets or dangerous endpoints. The jah site's ajax.php was an unauthenticated contact-form mailer (anyone could send mail through it) with a Gmail SMTP password hardcoded in the source. It was left behind, made unreachable, and the owner was told to rotate that password. Old PHP sites often hold credentials in plain files; grep for password, smtp, mysql before deploying anything.
  3. Set up the site on the new server: docroot, Apache vhost on :8008, nginx server block (see nginx in front of Apache (TLS proxy on :8008)), restorecon on the files (SELinux file contexts and booleans on web servers). Test it before DNS moves with curl --resolve example.com:443:<new-ip> https://example.com/ (or :80: before there is a cert).
  4. Get the certificate early by forwarding ACME challenges. In the old server's port-80 vhost, proxy /.well-known/acme-challenge/ to the new server. Let's Encrypt validates against the old IP, the request lands on the new server, and certbot --nginx -d example.com succeeds there while DNS still points at the old box.
  5. Make the old server a reverse proxy. In the old HTTPS vhost, replace the site with a proxy to the new server: SSLProxyEngine on, ProxyPreserveHost On, ProxyPass / https://<new-ip>/ (certificate verification off, since the cert's name won't match the IP). Now visitors on either address see the new site. Back up both old vhost files first.
  6. Flip the A record in the DNS manager. With a TTL of 86400 the switch trickles in over 24 hours; nobody sees an outage because the old server keeps forwarding. Check progress with dig @1.1.1.1 example.com.
  7. After a full TTL, the old-server edits are irrelevant. The old cert there can lapse.

Gotchas

See also

Linked from

Sources: jah memory (justinandrewhampton-site), home memory (reference_old_server), tldr post #1816 (2026-10-22)