/ http

How to rewrite all HTTP requests into HTTPS in NGINX

I wanted to redirect all http requests to https requests on one of my last projects.

I just added following strokes into my NGINX configuration file

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

server {
       listen         443 ssl;
       server_name    my.domain.com;
}