Nginx HTTP to HTTPS redirect for SSL

5.60K viewsNginxConfiguration FAQ Intermediate SSL

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


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

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


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

There’s a little more about this elsewhere on the site.