Nginx HTTP to HTTPS redirect for SSL

May 12, 2015 4054hotness 1likes 0comments
Questions LEMP Stack Q & ACategory: NginxNginx HTTP to HTTPS redirect for SSL
lempstack Staff asked 10 years ago
How do I configure Nginx to automatically forward HTTP requests to HTTPS for SSL?
1 Answers
lempstack Staff answered 6 years ago

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

server {
   listen [::]:80;
   listen 80;
  
   server_name oneinstack.com www.oneinstack.com;
  
   # and redirect to the https host (declared below)
   # avoiding http://www -> https://www -> https:// chain.
   return 301 https://oneinstack.com$request_uri;
 }

This person is a lazy dog and has left nothing