Q:

How to do redirection in NGINX

May I ask Where and How to redirect
http://domain.com, http://www, https://domain.com

to
https://www

?

A:

Where

In your Nginx config file (the main or vhost depending on your setup)

How

Try rewrite:
    server {
    listen      80;
    server_name www.domain.com domain.com;
    rewrite     ^ https://www.doamin.com$request_uri? permanent;
}

or return:
server {
    listen      80;
    server_name www.domain.com domain.com;
    return 301 https://www.domain.com$request_uri
}

Choice is your when it comes to Return vs Rewrite:

REWRITE 

Only the part of the original url that matches the regex is rewritten.
Slower than a Return.
Returns HTTP 302 (Moved Temporarily) in all cases, irrespective of permanent.
Suitable for temporary url changes. 

RETURN 

The entire url is rewritten to the url specified.
Faster response than rewrite.
Returns HTTP 301 (Moved Permanently).
Suitable for permanent changes to the url.
No need to set permanent.

Officila Nginx Docs on return/rewrite.

