Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
One nginx host file which handles domain.tld and www.domain.tld with and without https and redirects all of them to use https and www
server {
listen 80;
listen [::]:80;
server_name domain.tld www.domain.tld;
return 301 https://www.domain.tld$request_uri;
}
server {
listen 443 ssl http2;
listen [::]:443 ssl http2;
server_name www.domain.tld domain.tld;
if ($host=='domain.tld') {
return 301 https://www.domain.tld$request_uri;
}
root /whatever/your/webroot/is;
# include your HTTPS config here
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.