Skip to content

Instantly share code, notes, and snippets.

@dg
Created December 14, 2015 21:37
Show Gist options
  • Save dg/49c7845e34766c6b879a to your computer and use it in GitHub Desktop.
Save dg/49c7845e34766c6b879a to your computer and use it in GitHub Desktop.
Redirect to HTTPS for all except Windows XP
server {
...
listen 443 ssl;
listen 80;
if ($server_port = 80) {
set $xp A;
}
if ($http_user_agent !~ "Windows NT 5\.[12]") {
set $xp "${xp}B";
}
if ($xp = AB) {
return 301 https://$host$request_uri;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment