NginxRedirectHTTPS

nicolaw 27th April 2018 at 10:06am
NGINX TechnicalNotes

Generic VHost Catch-all

server {
  listen 80 default_server;
  listen [::]:80 default_server;
  server_name _;
  return 301 https://$host$request_uri;
}

Named VHosts

server {
  listen 80 default_server;
  listen [::]:80 default_server;
  server_name example.com www.example.com;
  return 301 https://$server_name$request_uri;
}