How to detect ssl in shared 80 / 443 ssl nginx server config?
http://nginx.org/en/docs/http/ngx_http_core_module.html#variables
- $https — “on” if connection operates in SSL mode, or an empty string otherwise
- $scheme — request scheme, “http” or “https”
For example, if you want to limit a location to https and only:
location /admin {
if ($https = "") {
return 404;
}
# ... and so on
}