Skip to content

Instantly share code, notes, and snippets.

@robmiller
Created May 2, 2013 12:27
Show Gist options
  • Save robmiller/5501879 to your computer and use it in GitHub Desktop.
Save robmiller/5501879 to your computer and use it in GitHub Desktop.
Set `$_SERVER['HTTPS']` in nginx, in the same way as it's done in Apache; this is necessary for example in WordPress, where the `is_ssl` check will otherwise fail (causing a redirect loop if you have `FORCE_SSL_ADMIN` on).
# The best place to put this is your `fastcgi_params` file.
set $_ssl "off";
# We run SSL on ports 443+, not just one port, to get
# around the lack of SNI in clients' browsers; you might
# safely be able to use "$server_port = 443"
if ( $server_port != 80 ) {
set $_ssl "on";
}
fastcgi_param HTTPS $_ssl;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment