Nginx HTTP to HTTPS redirect for SSL

3.10K views
0

How do I configure Nginx to automatically forward HTTP requests to HTTPS for SSL?

0

This server block uses the listen directive to accept requests on port 80 and supports IPv6.

server {
  listen [::]:80;
  listen 80;

  server_name lemp.io  www.lemp.io;

  # and redirect to the https host (declared below)
  # avoiding http://www -> https://www -> https:// chain.
  return 301 https://lemp.io$request_uri;
}

There’s a little more about this elsewhere on the site.
https://lemp.io/guides/nginx-redirect-quickstart/