Migrating in
6 answers
Bringing an existing nginx setup across.
Looking for something specific
The searchable index covers all 326 answers at once and filters as you type.
311 Import my existing nginx configuration
- Traffic, Import.
- Paste the file your sites are actually in, usually from
sites-enabledorconf.d. A top levelnginx.confis normally just a list of includes and shows you almost nothing. - Press See what it would make. This writes nothing at all.
- Read the Left alone section properly, untick anything you do not want, then import.
cat /etc/nginx/sites-enabled/*
Everything arrives switched off and unapplied, so you can look it over before turning it on.
312 Why did the import not bring my certificates?
Your configuration names certificate files by path. Those paths point at files on the machine the configuration came from, and the private keys are not in the text you pasted anyway.
So a site comes across knowing it uses https and with no certificate chosen. Afterwards, either get a new one from Let's Encrypt or upload the existing certificate and key.
313 The import made one site out of my two server blocks
Correct. You had two blocks for one name, one of which only forwarded to the other. That is one site here with the force https switch turned on, not two sites. The note under the site says exactly that.
314 The import says an upstream was never defined
Your configuration pointed at a pool declared in a file you did not paste. Paste that file too and preview again. Order does not matter, so you can paste several files one after another into the same box.
315 Move from HAProxy or Apache
The importer reads nginx configuration only. Coming from something else means building the sites and pools by hand, which for a handful of sites is an afternoon. Start with one site, get it working end to end, then repeat.
316 Cut over from an old load balancer without downtime
- Build the new fleet and configure the sites, but do not point any DNS at it.
- Test by adding the new addresses to your own hosts file, or by asking the new node directly with curl and a Host header.
- Get certificates on the new fleet using dns-01, so you do not have to move traffic first.
- Lower the TTL on the names you are moving, well in advance.
- Move one name at a time and watch it.
curl -sk -H "Host: shop.example.com" https://203.0.113.10/ -o /dev/null -w "%{http_code}\n"