Nginx - rewrite HTTP to HTTPS

A simple code snippet that can be used to rewrite HTTP request to HTTPS.

server {
	listen 80 default_server;
	server_name www.sleeplessbeastie.eu;
	return 301 $scheme://blog.sleeplessbeastie.eu;
}	

Sources

Nginx Pitfalls - Taxing Rewrites

Milosz Galazka's Picture

About Milosz Galazka

Milosz is a Linux Foundation Certified Engineer working for a successful Polish company as a system administrator and a long time supporter of Free Software Foundation and Debian operating system.

Gdansk, Poland https://sleeplessbeastie.eu