Scale up as you grow — whether you're running one virtual machine or ten thousand.

From GPU-powered inference and Kubernetes to managed databases and storage, get everything you need to build, scale, and deploy intelligent applications.

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.
Accepted Answer
Hi!
Because of the way TLS/SSL works, the whole handshake and encryption process must be done before receiving any HTTP headers or the response body (as all HTTP traffic is passed through the TLS/SSL ‘tunnel,’ so it has to be established first).
So you will have to create valid HTTPS server blocks for every one of the domains and configure that to redirect to the domain that you want.
server {
listen *:443 ssl;
server_name domain1.com;
ssl_certificate /path/to/domain1.crt;
ssl_certificate_key /path/to/domain1.key;
return 301 https://www.domain1.com$request_uri;
}
server {
listen *:443 ssl;
server_name domain2.com www.domain2.com;
ssl_certificate /path/to/domain2.crt;
ssl_certificate_key /path/to/domain2.key;
return 301 https://www.domain1.com$request_uri;
}
server {
listen *:443 ssl;
server_name domain3.com www.domain3.com;
ssl_certificate /path/to/domain3.crt;
ssl_certificate_key /path/to/domain3.key;
return 301 https://www.domain1.com$request_uri;
}