Skip to content

Instantly share code, notes, and snippets.

@kavichu
Created March 13, 2018 16:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kavichu/b9fc1dcaafd48c720890c2d414ced725 to your computer and use it in GitHub Desktop.
Save kavichu/b9fc1dcaafd48c720890c2d414ced725 to your computer and use it in GitHub Desktop.
Redirect HTTP to HTTPS Nginx
server {
	listen 80 default_server;
	listen [::]:80 default_server;
	server_name _;
	return 301 https://$host$request_uri;
}

or

server {
	listen 80 default_server;
	listen [::]:80 default_server;
	server_name example.com www.example.com;
	return 301 https://$server_name$request_uri;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment