Rewrite HTTP requests to HTTPS using Nginx

Rewrite HTTP requests to HTTPS using Nginx

By : -

A common task is to rewrite HTTP requests to HTTPS to secure communication. Using nginx, this is easily done with:

        # use only https
        if ($scheme = http) {
                rewrite ^ https://$host$uri permanent;
        }

This should be placed in a server block.

Leave a Reply

Your email address will not be published.