Simple nginx domain redirect

Linux nginx

Add to server block...

if ($host = example1.com) {
            return 301 https://example2.com$request_uri;
}